cybersecurity · beginner · ~15 min · safe pentest lab
Return a boolean verdict: is there a NOP run at least `threshold` long?
Turn the measurement into an alert:
int has_nop_sled(const unsigned char *buf, size_t n, int threshold);
Return 1 if any run of consecutive 0x90 bytes has length >= threshold, else 0. Treat threshold<1 as 1.
buf, and a threshold (>=1).
1 if a sled >= threshold exists, else 0.
threshold<1 is clamped to 1.
#include <stddef.h>
/* 1 if buf contains a run of >= threshold consecutive 0x90 bytes (threshold clamped to >=1). */
int has_nop_sled(const unsigned char *buf, size_t n, int threshold){ (void)buf;(void)n;(void)threshold; return 0; }
Off-by-one in the comparison (> vs >=); not clamping a non-positive threshold.
Empty buffer returns 0; exact-threshold run returns 1.
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.