blob: 028683d2fc410a4561b3e6c3c1ab731cc0ae912d [file] [log] [blame]
// Check that memset() call from a shared library gets intercepted.
// Please always keep this file in sync with
// ../Linux/
// RUN: %clangxx_asan -O0 %s -DSHARED_LIB \
// RUN: -shared -o \
// RUN: -fPIC -install_name @rpath/
// TODO(glider): figure out how to set rpath in a more portable way and unite
// this test with ../Linux/
// RUN: %clangxx_asan -O0 %s -o %t -Wl,-rpath,@executable_path && \
// RUN: not %run %t 2>&1 | FileCheck %s
#include <stdio.h>
#include <string.h>
#if defined(SHARED_LIB)
extern "C"
void my_memset(void *p, size_t sz) {
memset(p, 0, sz);
extern "C" void my_memset(void *p, size_t sz);
int main(int argc, char *argv[]) {
char buf[10];
my_memset(buf, 11);
// CHECK: {{.*ERROR: AddressSanitizer: stack-buffer-overflow}}
// CHECK: {{WRITE of size 11 at 0x.* thread T0}}
// CHECK: {{0x.* in my_memset .*}}
return 0;