File: src/main.zig:872-886
Severity: MEDIUM
Status: ✅ FIXED
New protocol.validPacketLength() helper (bounds: 5 ≤ len ≤ MAX_PACKET_SIZE)
is used by the client’s stream parser; oversized declared lengths now exit
cleanly instead of buffering forever. Mirrors the server-side MessageReader
bound.
Test: validPacketLength bounds — bug #375 (edge cases at both bounds
plus hostile maxInt(u32)).
const pkt_len = std.mem.readInt(u32, ...);
if (pkt_len < 5) {...}
if (read_buf.items.len - read_pos < pkt_len) break; // wait forever
No pkt_len <= protocol.MAX_PACKET_SIZE check (the server’s MessageReader has
one). A single flipped bit or hostile injection pins the client buffering
forever via ensureUnusedCapacity(4096) per POLLIN.
Reject pkt_len > MAX_PACKET_SIZE exactly like client.recvPacket does
(error.PacketTooLarge → disconnect). Test: feed a header declaring an absurd
length and expect clean failure.