Code RoomTLV parser bounds overflow
HardPrep Room Coding #4278

TLV parser bounds overflow

Vibe & agenticAlgorithms & data structuresSenior–Staff~22 min

An AI wrote this C parser for a TLV (type-length-value) record inside a custom binary protocol. Fuzzing crashed it within seconds. Find the off-by-one / bounds bug, the exact input that triggers it, and how you'd harden it.

Implement
parse_tlv_types(packet: list[int]) → list[int]
Examples
in[[1,0,2,65,66]]out[1]
in[[1,0,1,65,2,0,0,3,0,2,9,9]]out[1,2,3]
in[[7,255,255,1,2]]out[-1]
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.