summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/asan/output_tests/strncpy-overflow.cc
diff options
context:
space:
mode:
Diffstat (limited to 'compiler-rt/lib/asan/output_tests/strncpy-overflow.cc')
-rw-r--r--compiler-rt/lib/asan/output_tests/strncpy-overflow.cc9
1 files changed, 9 insertions, 0 deletions
diff --git a/compiler-rt/lib/asan/output_tests/strncpy-overflow.cc b/compiler-rt/lib/asan/output_tests/strncpy-overflow.cc
new file mode 100644
index 00000000000..044f6494bfa
--- /dev/null
+++ b/compiler-rt/lib/asan/output_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];
+}
OpenPOWER on IntegriCloud