fold/tests/fixtures/binary/cwe/cwe121_bof.c
trvon fd4a68dfff
test: add coverage for project graph, pcode encoder, and detector behaviors
Unit + integration coverage for the session's work: incremental project
graph/index, pcode encoder, unreachable/dead-branch, equiv/cross-TU,
div-by-zero/sign-conversion/int-truncation, use-after-free, quality-precision,
scan-router profile, source TU runner, detector plan, and the eval fixtures.
2026-08-16 16:46:07 -06:00

13 lines
367 B
C

// CWE-121: stack buffer overflow (strcpy into fixed 64-byte buffer).
#include <string.h>
#include <unistd.h>
__attribute__((noinline)) void vuln(const char* src) {
char buf[64];
strcpy(buf, src); // sink: unbounded copy -> stack BOF
write(1, buf, sizeof(buf));
}
int main(int argc, char** argv) {
if (argc > 1)
vuln(argv[1]);
return 0;
}