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: not %run %t 2>&1 | FileCheck --check-prefix=CHECK-ON %s
5 // FIXME: sprintf is not intercepted on Windows yet. But this test can
6 // pass if sprintf calls memmove, which is intercepted, so we can't XFAIL it.
7 // UNSUPPORTED: target={{.*windows-msvc.*}}
11 volatile char c
= '0';
13 volatile float f
= 1.239;
14 volatile char s
[] = "34";
16 fputs("before sprintf\n", stderr
);
17 sprintf((char *)buf
, "%c %d %.3f %s\n", c
, x
, f
, s
);
18 fputs("after sprintf", stderr
);
19 fputs((const char *)buf
, stderr
);
21 // Check that size of output buffer is sanitized.
22 // CHECK-ON: before sprintf
23 // CHECK-ON-NOT: after sprintf
24 // CHECK-ON: stack-buffer-overflow
25 // CHECK-ON-NOT: 0 12 1.239 34