mirror of
https://github.com/alexhopeoconnor/firmware.git
synced 2026-10-14 23:41:29 +10:00
Fix bug where UIDs, callsigns, and messages containing embedded null bytes (0x00) are truncated during compression/decompression. The issue occurs because strlen() stops at the first null byte, but nanopb char arrays can contain embedded nulls that are valid data. This causes Android device UIDs like "ANDROID-e7e455b40002429d" to be truncated to "ANDROID-e7e455b4" (16 chars instead of 24), breaking direct messages and contact identification. The fix adds a pb_string_length() helper that scans for the actual string length by finding the last non-null character, rather than stopping at the first null. Added comprehensive unit tests to prevent regressions: - Normal strings without embedded nulls - Strings with embedded null bytes - Empty strings and edge cases - Android UID pattern testing - Multiple embedded nulls scenarios Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>