cybersecurity · beginner · ~15 min

Would this write overflow?

Compare a write size against the buffer capacity.

Challenge

Implement int will_overflow(int write_len, int buf_size) returning 1 if writing write_len bytes into a buf_size buffer overflows it (write_len > buf_size), else 0.

Starter code

int will_overflow(int write_len, int buf_size) {
    /* TODO */
    return 0;
}

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