1 | // Check that memset() call from a shared library gets intercepted. |
2 | |
3 | // RUN: %clangxx_asan -O0 %s -DSHARED_LIB \ |
4 | // RUN: -shared -o %dynamiclib -fPIC %ld_flags_rpath_so |
5 | // RUN: %clangxx_asan -O0 %s -o %t %ld_flags_rpath_exe && \ |
6 | // RUN: not %run %t 2>&1 | FileCheck %s |
7 | |
8 | #include <stdio.h> |
9 | #include <string.h> |
10 | |
11 | #if defined(SHARED_LIB) |
12 | extern "C" |
13 | void my_memset(void *p, size_t sz) { |
14 | memset(p, 0, sz); |
15 | } |
16 | #else |
17 | extern "C" void my_memset(void *p, size_t sz); |
18 | |
19 | int main(int argc, char *argv[]) { |
20 | char buf[10]; |
21 | my_memset(p: buf, sz: 11); |
22 | // CHECK: {{.*ERROR: AddressSanitizer: stack-buffer-overflow}} |
23 | // CHECK: {{WRITE of size 11 at 0x.* thread T0}} |
24 | // CHECK: {{0x.* in my_memset .*interception-in-shared-lib-test.cpp:}}[[@LINE-10]] |
25 | return 0; |
26 | } |
27 | #endif |
28 | |