Pirama Arumuga Nainar | cdce50b | 2015-07-01 12:26:56 -0700 | [diff] [blame] | 1 | // RUN: %clang_safestack %s -o %t |
| 2 | // RUN: %run %t |
| 3 | |
| 4 | // RUN: %clang_nosafestack -fno-stack-protector %s -o %t |
| 5 | // RUN: not %run %t |
| 6 | |
| 7 | // Test that buffer overflows on the unsafe stack do not affect variables on the |
| 8 | // safe stack. |
| 9 | |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 10 | // REQUIRES: stable-runtime |
| 11 | |
Pirama Arumuga Nainar | cdce50b | 2015-07-01 12:26:56 -0700 | [diff] [blame] | 12 | __attribute__((noinline)) |
| 13 | void fct(volatile int *buffer) |
| 14 | { |
| 15 | memset(buffer - 1, 0, 7 * sizeof(int)); |
| 16 | } |
| 17 | |
| 18 | int main(int argc, char **argv) |
| 19 | { |
| 20 | int value1 = 42; |
| 21 | int buffer[5]; |
| 22 | int value2 = 42; |
| 23 | fct(buffer); |
| 24 | return value1 != 42 || value2 != 42; |
| 25 | } |