mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-26 06:45:20 +00:00
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:
@@ -90,7 +90,10 @@ final class BinaryProtocolTests: XCTestCase {
|
||||
}
|
||||
|
||||
// The encoded size should be smaller than uncompressed due to compression
|
||||
let headerSize = BinaryProtocol.headerSize(for: packet.version)
|
||||
guard let headerSize = BinaryProtocol.headerSize(for: packet.version) else {
|
||||
XCTFail("Invalid version")
|
||||
return
|
||||
}
|
||||
let uncompressedSize = headerSize + BinaryProtocol.senderIDSize + largePayload.count
|
||||
XCTAssertLessThan(encodedData.count, uncompressedSize)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user