brintos

brintos / llvm-project-archived public Read only

0
0
Text · 783 B · a838cb5 Raw
25 lines · cpp
1// RUN: %clangxx_asan  %s -o %t2// RUN: not %run %t   2>&1 | FileCheck %s --check-prefix=A13// RUN: not %run %t 1 2>&1 | FileCheck %s --check-prefix=A24// RUN: %env_asan_opts=intercept_memmem=0 %run %t5 6#include <string.h>7int main(int argc, char **argv) {8  char a1[] = {1, 2, 3, 4, 5, 6, 7, 8};9  char a2[] = {3, 4, 5};10  void *res;11  if (argc == 1)12    res = memmem(a1, sizeof(a1) + 1, a2, sizeof(a2));  // BOOM13  else14    res = memmem(a1, sizeof(a1), a2, sizeof(a2) + 1);  // BOOM15  // A1: AddressSanitizer: stack-buffer-overflow16  // A1: {{#0.*memmem}}17  // A1-NEXT: {{#1.*main}}18  // A1: 'a1'{{.*}} <== Memory access at offset19  //20  // A2: AddressSanitizer: stack-buffer-overflow21  // A2: {{#0.*memmem}}22  // A2: 'a2'{{.*}} <== Memory access at offset23  return res == NULL;24}25