28 lines · cpp
1// RUN: %clang_cl_asan %Od %p/dll_host.cpp %Fe%t2// RUN: %clang_cl_asan %LD %Od %s %Fe%t.dll3// RUN: not %run %t %t.dll 2>&1 | FileCheck %s4 5// On windows 64-bit, the memchr function is written in assembly and is not6// hookable with the interception library. There is not enough padding before7// the function and there is a short jump on the second instruction which8// doesn't not allow enough space to encode a 64-bit indirect jump.9// UNSUPPORTED: x86_64-windows10 11#include <string.h>12 13extern "C" __declspec(dllexport)14int test_function() {15 char buff[6] = "Hello";16 17 memchr(buff, 'z', 7);18// CHECK: AddressSanitizer: stack-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]19// CHECK: READ of size 7 at [[ADDR]] thread T020// CHECK-NEXT: memchr21// CHECK-NEXT: memchr22// CHECK-NEXT: test_function {{.*}}dll_intercept_memchr.cpp:[[@LINE-5]]23// CHECK: Address [[ADDR]] is located in stack of thread T0 at offset {{.*}} in frame24// CHECK-NEXT: test_function {{.*}}dll_intercept_memchr.cpp25// CHECK: 'buff'{{.*}} <== Memory access at offset {{.*}} overflows this variable26 return 0;27}28