summaryrefslogtreecommitdiff
path: root/test/asan/TestCases/Windows/global_const_string_oob.cc
diff options
context:
space:
mode:
Diffstat (limited to 'test/asan/TestCases/Windows/global_const_string_oob.cc')
-rw-r--r--test/asan/TestCases/Windows/global_const_string_oob.cc20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/asan/TestCases/Windows/global_const_string_oob.cc b/test/asan/TestCases/Windows/global_const_string_oob.cc
new file mode 100644
index 0000000000000..b39e3dbb3b4ef
--- /dev/null
+++ b/test/asan/TestCases/Windows/global_const_string_oob.cc
@@ -0,0 +1,20 @@
+// RUN: %clang_cl_asan -O0 %s -Fe%t
+// RUN: not %run %t 2>&1 | FileCheck %s
+
+#include <windows.h>
+#include <stdio.h>
+
+extern "C" const char *foo = "foobarspam";
+
+int main(void) {
+ if (foo[16])
+ printf("Boo\n");
+// CHECK-NOT: Boo
+// CHECK: AddressSanitizer: global-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
+// CHECK: READ of size 1 at [[ADDR]] thread T0
+// CHECK-NEXT: {{#0 .* main .*global_const_string_oob.cc:}}[[@LINE-5]]
+// CHECK: [[ADDR]] is located 5 bytes to the right of global variable [[STR:.*]] defined in {{'.*global_const_string_oob.cc:7:.*' .*}} of size 11
+// CHECK: [[STR]] is ascii string 'foobarspam'
+ return 0;
+}
+