Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Valgrind won't detect buffer overflow

#include <stdio.h>
main()
{     
    char buf[8];
    sprintf(buf,"AAAA%3s","XXssssssssXXXsssssXXX");
    printf("%s\n",buf);
}

I expected valgrind to detect a buffer overflow with the above code. But it does not report any errors or warnings. Do I need to enable any special flags for that?

like image 265
webminal.org Avatar asked Apr 24 '15 08:04

webminal.org


1 Answers

From Valgrind Tutorial

What valgrind is NOT

Although valgrind is an extremely useful program, it will not miraculously tell you about every memory bug in your program. There are several limitations that you should keep in mind. It does not do bounds checking on stack/static arrays ..

like image 128
Dayal rai Avatar answered Oct 18 '22 08:10

Dayal rai