summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/asan/lit_tests/TestCases/memcmp_strict_test.cc
blob: a29282b01135423cd68d7c3e7f5a9895d366142b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// RUN: %clangxx_asan -O0 %s -o %t && ASAN_OPTIONS=strict_memcmp=0 %t 2>&1 | FileCheck %s --check-prefix=CHECK-nonstrict
// RUN: %clangxx_asan -O0 %s -o %t && ASAN_OPTIONS=strict_memcmp=1 %t 2>&1 | FileCheck %s --check-prefix=CHECK-strict
// Default to strict_memcmp=1.
// RUN: %clangxx_asan -O0 %s -o %t && %t 2>&1 | FileCheck %s --check-prefix=CHECK-strict

#include <stdio.h>
#include <string.h>
int main() {
  char kFoo[] = "foo";
  char kFubar[] = "fubar";
  int res = memcmp(kFoo, kFubar, strlen(kFubar));
  printf("res: %d\n", res);
  // CHECK-nonstrict: {{res: -1}}
  // CHECK-strict: AddressSanitizer: stack-buffer-overflow
  return 0;
}
OpenPOWER on IntegriCloud