Fix critical issues from PR #681 review

Critical fixes:
- BinaryProtocol: Return nil for unknown versions (prevents buffer underflows)
- Add BinaryProtocol.Offsets struct to centralize magic numbers
- Replace magic offset calculations with named constants

Security/Privacy:
- FileAttachmentView: Use url.lastPathComponent instead of url.path
  (prevents exposing full system paths)

Documentation:
- Fix compression algorithm documentation (zlib, not LZ4)

All tests passing.
This commit is contained in:
jack
2025-10-14 22:26:03 +02:00
parent 367addf138
commit 747551f35a
5 changed files with 26 additions and 15 deletions
@@ -140,9 +140,8 @@ final class NotificationStreamAssemblerTests: XCTestCase {
return XCTFail("Failed to encode packet frame")
}
let flagsOffset = 1 + 1 + 1 + 8
XCTAssertLessThan(flagsOffset, frame.count)
let flags = frame[frame.startIndex + flagsOffset]
XCTAssertLessThan(BinaryProtocol.Offsets.flags, frame.count)
let flags = frame[frame.startIndex + BinaryProtocol.Offsets.flags]
XCTAssertNotEqual(flags & BinaryProtocol.Flags.isCompressed, 0, "Frame should be compressed for large payloads")
let splitIndex = min(4096, frame.count / 2)