Test case 3

Write or BOF on dynamically-allocated memory. See the code snippet as follows:

/* test case 3 : out-of-bounds : write overflow [on dynamic memory] */static void write_overflow_dynmem(void){    char *dest, src[] = "abcd56789";    dest = malloc(8);    if (!dest)     FATAL("malloc failed\n");    strcpy(dest, src); /* Bug: write overflow */    free(dest);}

Again, no compile or runtime detection of the bug occurs:

$ ./membugs 3$ ./membugs 3           << try once more >>$ 
Unfortunately, BOF-related bugs and vulnerabilities tend to be quite common in the industry. The root cause is poorly understood, and thus results in poorly written, code; this is where we, as developers, must step up our game! For real-world examples of security vulnerabilities, please see ...

Get Hands-On System Programming with Linux now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.