diff options
Diffstat (limited to 'lib/asan/tests/strncpy-overflow.cc')
-rw-r--r-- | lib/asan/tests/strncpy-overflow.cc | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/asan/tests/strncpy-overflow.cc b/lib/asan/tests/strncpy-overflow.cc new file mode 100644 index 000000000000..044f6494bfa1 --- /dev/null +++ b/lib/asan/tests/strncpy-overflow.cc @@ -0,0 +1,9 @@ +#include <string.h> +#include <stdlib.h> +int main(int argc, char **argv) { + char *hello = (char*)malloc(6); + strcpy(hello, "hello"); + char *short_buffer = (char*)malloc(9); + strncpy(short_buffer, hello, 10); // BOOM + return short_buffer[8]; +} |