cybersecurity · beginner · ~15 min · safe pentest lab

Minimum-size guard

Bail out on short fuzz input.

Challenge

Write the guard a fuzz target uses first: is there enough input to read a fixed-size header?

Task

Implement int size_guard(int size, int header_size) that returns 1 if size >= header_size, else 0.

Input

  • size: the length of the fuzzer-supplied input.
  • header_size: the number of bytes the parser needs up front.

Output

Returns int: 1 if there is enough input (size >= header_size), else 0.

Example

size_guard(10, 8)   ->   1
size_guard(8, 8)    ->   1   (exactly enough)
size_guard(4, 8)    ->   0   (too short)

Edge cases

  • size exactly equal to header_size is enough (return 1).

Rules

  • Simple comparison — the first line of a robust parser.

Input format

Two ints: the input size and the required header_size.

Output format

An int: 1 if size >= header_size, else 0.

Constraints

size == header_size counts as enough.

Starter code

int size_guard(int size, int header_size) {
    /* TODO */
    return 0;
}

Solve this exercise in the browser editor — compile and run against the test harness, no setup required.