1*7c3d14c8STreehugger Robot // RUN: %clang_asan -O2 %s -o %t 2*7c3d14c8STreehugger Robot // RUN: %env_asan_opts=check_printf=1 not %run %t 2>&1 | FileCheck --check-prefix=CHECK-ON %s 3*7c3d14c8STreehugger Robot // RUN: not %run %t 2>&1 | FileCheck --check-prefix=CHECK-ON %s 4*7c3d14c8STreehugger Robot 5*7c3d14c8STreehugger Robot // FIXME: sprintf is not intercepted on Windows yet. 6*7c3d14c8STreehugger Robot // XFAIL: win32 7*7c3d14c8STreehugger Robot 8*7c3d14c8STreehugger Robot #include <stdio.h> main()9*7c3d14c8STreehugger Robotint main() { 10*7c3d14c8STreehugger Robot volatile char c = '0'; 11*7c3d14c8STreehugger Robot volatile int x = 12; 12*7c3d14c8STreehugger Robot volatile float f = 1.239; 13*7c3d14c8STreehugger Robot volatile char s[] = "34"; 14*7c3d14c8STreehugger Robot volatile char buf[2]; 15*7c3d14c8STreehugger Robot fputs("before sprintf\n", stderr); 16*7c3d14c8STreehugger Robot sprintf((char *)buf, "%c %d %.3f %s\n", c, x, f, s); 17*7c3d14c8STreehugger Robot fputs("after sprintf", stderr); 18*7c3d14c8STreehugger Robot fputs((const char *)buf, stderr); 19*7c3d14c8STreehugger Robot return 0; 20*7c3d14c8STreehugger Robot // Check that size of output buffer is sanitized. 21*7c3d14c8STreehugger Robot // CHECK-ON: before sprintf 22*7c3d14c8STreehugger Robot // CHECK-ON-NOT: after sprintf 23*7c3d14c8STreehugger Robot // CHECK-ON: stack-buffer-overflow 24*7c3d14c8STreehugger Robot // CHECK-ON-NOT: 0 12 1.239 34 25*7c3d14c8STreehugger Robot } 26