1 // RUN: %clang_asan -O2 %s -o %t
2 // RUN: %env_asan_opts=check_printf=1 not %run %t 2>&1 | FileCheck --check-prefix=CHECK-ON %s
3 // RUN: %env_asan_opts=check_printf=0 %run %t 2>&1 | FileCheck --check-prefix=CHECK-OFF %s
4 // RUN: not %run %t 2>&1 | FileCheck --check-prefix=CHECK-ON %s
5
6 // FIXME: printf is not intercepted on Windows yet.
7 // XFAIL: win32
8
9 #include <stdio.h>
main()10 int main() {
11 #ifdef _MSC_VER
12 // FIXME: The test raises a dialog even though it's XFAILd.
13 return 42;
14 #endif
15 volatile char c = '0';
16 volatile int x = 12;
17 volatile float f = 1.239;
18 volatile char s[] = "34";
19 volatile int n[1];
20 printf("%c %d %.3f %s%n\n", c, x, f, s, &n[1]);
21 return 0;
22 // Check that %n is sanitized.
23 // CHECK-ON: stack-buffer-overflow
24 // CHECK-ON-NOT: 0 12 1.239 34
25 // CHECK-OFF: 0 12 1.239 34
26 }
27