cybersecurity · intermediate · ~15 min
Validate an offset+length against a buffer, overflow-aware.
Implement int range_ok(int start, int len, int total) returning 1 if reading len bytes from offset start stays within total (start >= 0, len >= 0, and start + len <= total), else 0.
int range_ok(int start, int len, int total) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.