Security Operations

A fuzzer crashes a C parser. A length field set to its maximum value wraps to zero after the parser adds a header size, a tiny heap buffer is allocated, and the full payload is then copied in. Which change best fixes the root cause?

Show the answer

Correct answerD. Check the length for wraparound before computing the allocation size

AWhy not this: Zeroing freed blocks targets use-after-free data leaks, and this flaw involves no freed memory.

BWhy not this: ASLR makes exploitation harder but leaves the undersized allocation and overflow in place.

CWhy not this: Canaries detect stack smashing, but this overwrite happens in a heap buffer.

DWhy this is right: Checking the arithmetic stops the wrapped size and so the undersized allocation that the copy overruns.

The flaw is an integer overflow in the size calculation that leads to a heap buffer overflow. Validating the length and using checked arithmetic removes the cause. Stack canaries guard return addresses on the stack, so they would not stop this heap overwrite.