Code RoomLength-prefixed blob allocation DoS
HardPrep Room Coding #4285

Length-prefixed blob allocation DoS

Vibe & agenticAlgorithms & data structuresSenior–Staff~20 min

An AI wrote this Rust function to read a length-prefixed blob from a stream into a pre-sized Vec. It compiles cleanly and looks idiomatic. Identify the denial-of-service / integer bug, the packet that triggers it, and the fix.

Implement
planned_allocation(header_bytes: list[int], max_blob: int, chunk_cap: int) → int
Examples
in[[0,0,4,0],1048576,65536]out1024
in[[255,255,255,255],1048576,65536]out-1
in[[0,1,0,0],1048576,65536]out65536
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 20 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.