brintos

brintos / llvm-project-archived public Read only

0
0
Text · 720 B · 2b31e64 Raw
22 lines · c
1// RUN: %clang_asan %s -o %t2// RUN: %env_asan_opts=intercept_strcmp=false %run %t 2>&13// RUN: %env_asan_opts=intercept_strcmp=true not %run %t 2>&1 | FileCheck %s4// RUN:                                      not %run %t 2>&1 | FileCheck %s5 6#include <assert.h>7#include <stdlib.h>8#include <string.h>9 10int main(int argc, char **argv) {11  char s1[] = "abcd";12  char s2[] = "1234";13  assert(strcmp(s1, s2) > 0);14  assert(strcmp(s1 - 1, s2));15 16  // CHECK: {{.*ERROR: AddressSanitizer: stack-buffer-underflow on address}}17  // Very rarely `s1[-1]` happens to be '1', resulting in `strcmp` needing to18  // check 2 bytes before failing, rather than 1 - this should still pass19  // CHECK: READ of size {{[12]}}20  return 0;21}22