blob: b2a14ff4f25aaf9abf4324293c9bad1e6fd03c36 [file] [log] [blame]
Stephen Hines2d1fdb22014-05-28 23:58:16 -07001// RUN: %clang_asan -O2 %s -o %t
2// We need replace_str=0 and replace_intrin=0 to avoid reporting errors in
3// strlen() and memcpy() called by puts().
Pirama Arumuga Nainarcdce50b2015-07-01 12:26:56 -07004// RUN: env ASAN_OPTIONS=$ASAN_OPTIONS:replace_str=0:replace_intrin=0:check_printf=1 not %run %t 2>&1 | FileCheck --check-prefix=CHECK-ON %s
5// RUN: env ASAN_OPTIONS=$ASAN_OPTIONS:replace_str=0:replace_intrin=0 not %run %t 2>&1 | FileCheck --check-prefix=CHECK-ON %s
Stephen Hines2d1fdb22014-05-28 23:58:16 -07006
Stephen Hines6a211c52014-07-21 00:49:56 -07007// FIXME: printf is not intercepted on Windows yet.
8// XFAIL: win32
9
Stephen Hines2d1fdb22014-05-28 23:58:16 -070010#include <stdio.h>
11int main() {
12 volatile char c = '0';
13 volatile int x = 12;
14 volatile float f = 1.239;
15 volatile char s[] = "34";
16 volatile char buf[2];
17 sprintf((char *)buf, "%c %d %.3f %s\n", c, x, f, s);
18 puts((const char *)buf);
19 return 0;
20 // Check that size of output buffer is sanitized.
21 // CHECK-ON: stack-buffer-overflow
22 // CHECK-ON-NOT: 0 12 1.239 34
23}