jack 774c88ed97
Cap packet payload size per type and bound sync stores by bytes (#1719)
The decoder accepted a payload of any type up to the framed-file
ceiling, compressed or not, and the stores holding decoded packets
evicted by count only.

- New PacketPayloadLimits (BitFoundation): per-type decoded payload
  caps, enforced in BinaryProtocol.decodeCore for compressed and
  uncompressed payloads. Only fileTransfer and noiseEncrypted keep the
  framed-file cap; every other type is capped at >= 2x the largest
  payload current iOS and Android encoders produce.
- The unreachable 50,000:1 ratio guard becomes DEFLATE's 1032:1 bound.
- Fragment reassembly is limited by the claimed type's frame ceiling,
  and a reassembled packet of a different type is dropped.
- Gossip PacketStores, archive restore and the directed relay spool
  get byte budgets alongside their count caps.
- Broadcast file transfers are validated before being tracked for sync.
- Public mesh messages larger than a v1 frame are not delivered.

Receive-side only; senders and the wire format are unchanged.
Also: a re-delivered fragment replaces its index's bytes in the assembly
size projection instead of counting twice, and a test-harness race in
GossipSyncManagerTests.concurrentPacketIntakeAndSyncRequest is fixed.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-23 20:19:59 +02:00
..