Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 1 | // RUN: %clang_asan -O2 %s -o %t |
Pirama Arumuga Nainar | cdce50b | 2015-07-01 12:26:56 -0700 | [diff] [blame] | 2 | // RUN: env ASAN_OPTIONS=$ASAN_OPTIONS:check_printf=1 not %run %t 2>&1 | FileCheck --check-prefix=CHECK-ON %s |
| 3 | // RUN: env ASAN_OPTIONS=$ASAN_OPTIONS:check_printf=0 %run %t 2>&1 | FileCheck --check-prefix=CHECK-OFF %s |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 4 | // RUN: not %run %t 2>&1 | FileCheck --check-prefix=CHECK-ON %s |
| 5 | |
Stephen Hines | 6a211c5 | 2014-07-21 00:49:56 -0700 | [diff] [blame] | 6 | // FIXME: printf is not intercepted on Windows yet. |
| 7 | // XFAIL: win32 |
| 8 | |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 9 | #include <stdio.h> |
| 10 | int main() { |
| 11 | volatile char c = '0'; |
| 12 | volatile int x = 12; |
| 13 | volatile float f = 1.239; |
| 14 | volatile char s[] = "34"; |
| 15 | volatile int n[1]; |
| 16 | printf("%c %d %.3f %s%n\n", c, x, f, s, &n[1]); |
| 17 | return 0; |
| 18 | // Check that %n is sanitized. |
| 19 | // CHECK-ON: stack-buffer-overflow |
| 20 | // CHECK-ON-NOT: 0 12 1.239 34 |
| 21 | // CHECK-OFF: 0 12 1.239 34 |
| 22 | } |