28 lines · c
1// RUN: %clang_asan -Wno-excess-initializers -O2 %s -o %t2// We need replace_intrin=0 to avoid reporting errors in memcpy.3// RUN: %env_asan_opts=replace_intrin=0:check_printf=1 not %run %t 2>&1 | FileCheck --check-prefix=CHECK-ON %s4// RUN: %env_asan_opts=replace_intrin=0:check_printf=0 %run %t 2>&1 | FileCheck --check-prefix=CHECK-OFF %s5// RUN: %env_asan_opts=replace_intrin=0 not %run %t 2>&1 | FileCheck --check-prefix=CHECK-ON %s6 7// FIXME: printf is not intercepted on Windows yet.8// XFAIL: target={{.*windows-(msvc.*|gnu)}}9 10// FIXME: The test is flaky after build bot upgrade. #9751511// UNSUPPORTED: android12 13#include <stdio.h>14#include <string.h>15int main() {16 volatile char c = '0';17 volatile int x = 12;18 volatile float f = 1.239;19 volatile char s[] = "34";20 volatile char fmt[2] = "%c %d %f %s\n";21 printf((char *)fmt, c, x, f, s);22 return 0;23 // Check that format string is sanitized.24 // CHECK-ON: stack-buffer-overflow25 // CHECK-ON-NOT: 0 12 1.239 3426 // CHECK-OFF: 027}28