cybersecurity · intermediate · ~15 min
Defend every access against the fuzzer's arbitrary size.
A fuzz target gets arbitrary data/size. Implement int safe_byte(const unsigned char *data, int size, int idx) returning data[idx] if 0 <= idx < size, else -1 — so the parser never reads out of bounds.
int safe_byte(const unsigned char *data, int size, int idx) {
/* TODO */
return -1;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.