From 3da1400d07e473463df86668e1e50da8b02618fa Mon Sep 17 00:00:00 2001 From: dim Date: Sun, 6 Sep 2015 18:41:23 +0000 Subject: Import compiler-rt 3.7.0 release (r246257). --- test/safestack/overflow.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 test/safestack/overflow.c (limited to 'test/safestack/overflow.c') diff --git a/test/safestack/overflow.c b/test/safestack/overflow.c new file mode 100644 index 0000000..14e2982 --- /dev/null +++ b/test/safestack/overflow.c @@ -0,0 +1,23 @@ +// RUN: %clang_safestack %s -o %t +// RUN: %run %t + +// RUN: %clang_nosafestack -fno-stack-protector %s -o %t +// RUN: not %run %t + +// Test that buffer overflows on the unsafe stack do not affect variables on the +// safe stack. + +__attribute__((noinline)) +void fct(volatile int *buffer) +{ + memset(buffer - 1, 0, 7 * sizeof(int)); +} + +int main(int argc, char **argv) +{ + int value1 = 42; + int buffer[5]; + int value2 = 42; + fct(buffer); + return value1 != 42 || value2 != 42; +} -- cgit v1.1