forked from OSchip/llvm-project
[ASan] Fix printf-5.c on OSX: fix a compiler warning, avoid intercepting memcpy (which triggers the error report before printf does).
llvm-svn: 200751
This commit is contained in:
parent
9244c48b29
commit
40fcff653c
|
@ -1,7 +1,8 @@
|
|||
// RUN: %clang_asan -O2 %s -o %t
|
||||
// RUN: ASAN_OPTIONS=check_printf=1 not %t 2>&1 | FileCheck --check-prefix=CHECK-ON %s
|
||||
// RUN: ASAN_OPTIONS=check_printf=0 %t 2>&1 | FileCheck --check-prefix=CHECK-OFF %s
|
||||
// RUN: %t 2>&1 | FileCheck --check-prefix=CHECK-OFF %s
|
||||
// We need replace_intrin=0 to avoid reporting errors in memcpy.
|
||||
// RUN: ASAN_OPTIONS=replace_intrin=0:check_printf=1 not %t 2>&1 | FileCheck --check-prefix=CHECK-ON %s
|
||||
// RUN: ASAN_OPTIONS=replace_intrin=0:check_printf=0 %t 2>&1 | FileCheck --check-prefix=CHECK-OFF %s
|
||||
// RUN: ASAN_OPTIONS=replace_intrin=0 %t 2>&1 | FileCheck --check-prefix=CHECK-OFF %s
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
@ -12,7 +13,7 @@ int main() {
|
|||
volatile char s[] = "34";
|
||||
volatile char fmt[2];
|
||||
memcpy((char *)fmt, "%c %d %f %s\n", sizeof(fmt));
|
||||
printf(fmt, c, x, f, s);
|
||||
printf((char *)fmt, c, x, f, s);
|
||||
return 0;
|
||||
// Check that format string is sanitized.
|
||||
// CHECK-ON: stack-buffer-overflow
|
||||
|
|
Loading…
Reference in New Issue