brintos

brintos / llvm-project-archived public Read only

0
0
Text · 636 B · baeac1c Raw
32 lines · c
1// RUN: %clang_safestack %s -o %t2// RUN: %run %t3 4// RUN: %clang_nosafestack -fno-stack-protector %s -o %t5// RUN: not %run %t6 7// Test that buffer overflows on the unsafe stack do not affect variables on the8// safe stack.9 10// REQUIRES: stable-runtime11 12extern void *memset(void *, int, __typeof__(sizeof(0)));13 14__attribute__((noinline))15void fct(volatile int *buffer)16{17  memset(buffer - 1, 0, 7 * sizeof(int));18}19 20int main(int argc, char **argv)21{22  int prebuf[7];23  int value1 = 42;24  int buffer[5];25  int value2 = 42;26  int postbuf[7];27  fct(prebuf + 1);28  fct(postbuf + 1);29  fct(buffer);30  return value1 != 42 || value2 != 42;31}32