cybersecurity · beginner · ~15 min

Enough input to parse?

Check minimum input length before parsing.

Challenge

Write the length guard a fuzz target uses before reading a fixed-size header.

Task

Implement int enough_input(int size, int needed) that returns 1 if size >= needed, else 0.

Input

  • size: the length of the fuzzer-supplied input.
  • needed: the minimum number of bytes the parser requires.

Output

Returns int: 1 if size >= needed, else 0.

Example

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

Edge cases

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

Rules

  • Simple comparison.

Input format

Two ints: the input size and the required needed.

Output format

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

Constraints

size == needed counts as enough.

Starter code

int enough_input(int size, int needed) {
    /* TODO */
    return 0;
}

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