brintos

brintos / llvm-project-archived public Read only

0
0
Text · 909 B · 94cb6aa Raw
29 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#include <stdio.h>6#include <string.h>7 8extern "C" __declspec(dllexport)9int test_function() {10  char str[] = "Hello!";11  if (6 != strlen(str))12    return 1;13  printf("Initial test OK\n");14  fflush(0);15// CHECK: Initial test OK16 17  str[6] = '!';  // Removes '\0' at the end!18  int len = strlen(str);19// CHECK: AddressSanitizer: stack-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]20// FIXME: Should be READ of size 1, see issue 155.21// CHECK: READ of size {{[0-9]+}} at [[ADDR]] thread T022// CHECK-NEXT: {{#0 .*}}strlen23// CHECK-NEXT: {{#1 .* test_function .*}}dll_intercept_strlen.cpp:[[@LINE-5]]24//25// CHECK: Address [[ADDR]] is located in stack of thread T0 at offset {{.*}} in frame26// CHECK-NEXT: test_function {{.*}}dll_intercept_strlen.cpp:27  return len > 42;28}29