cybersecurity · intermediate · ~15 min · safe pentest lab
Recognise the terminator-canary design.
Recognise a terminator canary — a canary whose low byte is 0x00 so that string functions stop before cleanly overwriting it.
Implement int is_terminator_canary(unsigned long c) that returns 1 if the low byte of c is 0, and 0 otherwise.
c: a candidate canary value (unsigned long).Returns 1 if (c & 0xFF) == 0, 0 otherwise.
is_terminator_canary(0xdeadbe00) -> 1 (low byte is 0)
is_terminator_canary(0xdeadbeef) -> 0
A candidate canary value c (unsigned long).
1 if the low byte of c is 0; otherwise 0.
Test (c & 0xFF) == 0.
int is_terminator_canary(unsigned long c) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.