[CI][Github] Do not fail premerge job
[llvm-project.git] / compiler-rt / test / asan / TestCases / Linux / printf-fortify-4.c
blobdb89ca2037f67389224c6312b10ff082b0914a24
1 // RUN: %clang -fPIC -shared -O2 -D_FORTIFY_SOURCE=2 -D_DSO %s -o %t.so
2 // RUN: %clang_asan %s -o %t %t.so
3 // RUN: not %run %t 2>&1 | FileCheck %s
4 // REQUIRES: glibc-2.27
5 #ifdef _DSO
6 #include <stdarg.h>
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <string.h>
10 __attribute__((noinline)) char foo(const char *format, ...) {
11 char *write_buffer = (char *)malloc(1);
12 va_list ap;
13 va_start(ap, format);
14 // CHECK: AddressSanitizer: heap-buffer-overflow
15 vsnprintf(write_buffer, 4096, format, ap);
16 va_end(ap);
17 return write_buffer[0];
19 #else
20 extern int foo(const char *format, ...);
21 int main() { return foo("%s_%s", "one", "two"); }
22 #endif