Code RoomPacket name field heap overflow
HardPrep Room Coding #4283

Packet name field heap overflow

Vibe & agenticAlgorithms & data structuresSenior–Staff~22 min

An AI generated this C++ code to copy a variable-length name field out of a received packet into a fixed struct. Code review missed it; a fuzzer found a heap overflow. Identify the memory bug, the packet that triggers it, and the safe rewrite.

Implement
parse_peer_frame(packet: list[int], name_capacity: int) → list[int]
Examples
in[[3,97,98,99,1,187],32]out[3,443]
in[[255,65,66],32]out[]
in[[0,1,187],32]out[0,443]
What a strong answer looks like

Treat the AI’s output as a draft to verify, not an answer to trust. Name the specific flaw and the input that triggers it, say how you’d catch it (tests, edge cases, reading critically), and how you’d re-prompt or decompose to get it right.

0:00 of about 22 min

Vibe & agentic: describe the solution in plain language (or narrate it) and the coach grades your approach.

Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.