19 lines · c
1// RUN: %clang -fPIC -shared -O2 -D_FORTIFY_SOURCE=2 -D_DSO %s -o %t.so2// RUN: %clang_asan -o %t %t.so %s3// RUN: not %run %t 2>&1 | FileCheck %s4// REQUIRES: glibc-2.275#ifdef _DSO6#include <stdio.h>7#include <stdlib.h>8#include <string.h>9__attribute__((noinline)) int foo() {10 char *write_buffer = (char *)malloc(1);11 // CHECK: AddressSanitizer: heap-buffer-overflow12 sprintf(write_buffer, "%s_%s", "one", "two");13 return write_buffer[0];14}15#else16extern int foo();17int main() { return foo(); }18#endif19