Files
clang-p2996/compiler-rt/test/asan/TestCases/huge_negative_hea_oob.cpp
Florian Mayer be366041fa [ASan] rename left/right to before/after.
left/right is a weird way to refer to address ordering.

Reviewed By: eugenis, MaskRay

Differential Revision: https://reviews.llvm.org/D132611
2022-09-06 13:25:15 -07:00

14 lines
428 B
C++

// RUN: %clangxx_asan %s -o %t && not %run %t 2>&1 | FileCheck %s
// RUN: %clangxx_asan -O %s -o %t && not %run %t 2>&1 | FileCheck %s
// Check that we can find huge buffer overflows before.
#include <stdlib.h>
#include <string.h>
int main(int argc, char **argv) {
char *x = (char*)malloc(1 << 20);
memset(x, 0, 10);
int res = x[-argc * 4000]; // BOOOM
// CHECK: is located 4000 bytes before
free(x);
return res;
}