1*7c3d14c8STreehugger Robot // RUN: %clang_asan -O2 %s -o %t 2*7c3d14c8STreehugger Robot // We need replace_intrin=0 to avoid reporting errors in memcpy. 3*7c3d14c8STreehugger Robot // RUN: %env_asan_opts=replace_intrin=0:check_printf=1 not %run %t 2>&1 | FileCheck --check-prefix=CHECK-ON %s 4*7c3d14c8STreehugger Robot // RUN: %env_asan_opts=replace_intrin=0:check_printf=0 %run %t 2>&1 | FileCheck --check-prefix=CHECK-OFF %s 5*7c3d14c8STreehugger Robot // RUN: %env_asan_opts=replace_intrin=0 not %run %t 2>&1 | FileCheck --check-prefix=CHECK-ON %s 6*7c3d14c8STreehugger Robot 7*7c3d14c8STreehugger Robot // FIXME: printf is not intercepted on Windows yet. 8*7c3d14c8STreehugger Robot // XFAIL: win32 9*7c3d14c8STreehugger Robot 10*7c3d14c8STreehugger Robot #include <stdio.h> 11*7c3d14c8STreehugger Robot #include <string.h> main()12*7c3d14c8STreehugger Robotint main() { 13*7c3d14c8STreehugger Robot volatile char c = '0'; 14*7c3d14c8STreehugger Robot volatile int x = 12; 15*7c3d14c8STreehugger Robot volatile float f = 1.239; 16*7c3d14c8STreehugger Robot volatile char s[] = "34"; 17*7c3d14c8STreehugger Robot volatile char fmt[2]; 18*7c3d14c8STreehugger Robot memcpy((char *)fmt, "%c %d %f %s\n", sizeof(fmt)); 19*7c3d14c8STreehugger Robot printf((char *)fmt, c, x, f, s); 20*7c3d14c8STreehugger Robot return 0; 21*7c3d14c8STreehugger Robot // Check that format string is sanitized. 22*7c3d14c8STreehugger Robot // CHECK-ON: stack-buffer-overflow 23*7c3d14c8STreehugger Robot // CHECK-ON-NOT: 0 12 1.239 34 24*7c3d14c8STreehugger Robot // CHECK-OFF: 0 25*7c3d14c8STreehugger Robot } 26