Code Room
Vibe codingHard
Question
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.
// pkt points at a buffer of total length pkt_lenint parse_tlv(const uint8_t *pkt, size_t pkt_len) { size_t off = 0; while (off < pkt_len) { uint8_t type = pkt[off]; uint16_t len = (pkt[off+1] << 8) | pkt[off+2]; const uint8_t *val = &pkt[off + 3]; handle_tlv(type, val, len); // reads len bytes from val off += 3 + len; } return 0;}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.
Learn the concepts
Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.
Run or narrate your approach, then ask the coach.