blob: b219d6f8bc91f0183a5b014dc4db8713efc0c8ac [file] [log] [blame]
Alexey Samsonov00cd2732014-01-21 11:58:33 +00001// RUN: %clang_asan -O2 %s -o %t
Alexander Potapenko844a3cf2014-02-04 11:32:05 +00002// We need replace_str=0 and replace_intrin=0 to avoid reporting errors in
3// strlen() and memcpy() called by puts().
Timur Iskhodzhanovd67df362014-05-26 13:44:57 +00004// RUN: env 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=replace_str=0:replace_intrin=0 not %run %t 2>&1 | FileCheck --check-prefix=CHECK-ON %s
Alexey Samsonov00cd2732014-01-21 11:58:33 +00006
7#include <stdio.h>
8int main() {
9 volatile char c = '0';
10 volatile int x = 12;
11 volatile float f = 1.239;
12 volatile char s[] = "34";
13 volatile char buf[2];
14 sprintf((char *)buf, "%c %d %.3f %s\n", c, x, f, s);
15 puts((const char *)buf);
16 return 0;
17 // Check that size of output buffer is sanitized.
18 // CHECK-ON: stack-buffer-overflow
19 // CHECK-ON-NOT: 0 12 1.239 34
Alexey Samsonov00cd2732014-01-21 11:58:33 +000020}