brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.0 KiB · ef0ac35 Raw
30 lines · cpp
1// Test that small memcpy works correctly.2 3// RUN: %clangxx_asan %s -o %t4// RUN: not %run %t 8 24 2>&1 | FileCheck %s --check-prefix=CHECK5// RUN: not %run %t 16 32 2>&1 | FileCheck %s --check-prefix=CHECK6// RUN: not %run %t 24 40 2>&1 | FileCheck %s --check-prefix=CHECK7// RUN: not %run %t 32 48 2>&1 | FileCheck %s --check-prefix=CHECK8// RUN: not %run %t 40 56 2>&1 | FileCheck %s --check-prefix=CHECK9// RUN: not %run %t 48 64 2>&1 | FileCheck %s --check-prefix=CHECK10// REQUIRES: shadow-scale-311#include <assert.h>12#include <string.h>13#include <stdlib.h>14#include <stdio.h>15 16#include <sanitizer/asan_interface.h>17 18int main(int argc, char **argv) {19  assert(argc == 3);20  size_t poison_from = atoi(argv[1]);21  size_t poison_to = atoi(argv[2]);22  assert(poison_from <= poison_to);23  char A1[64], A2[64];24  fprintf(stderr, "%zd %zd\n", poison_from, poison_to - poison_from);25  __asan_poison_memory_region(&A1[0] + poison_from, poison_to - poison_from);26  memcpy(A1, A2, sizeof(A1));27// CHECK: AddressSanitizer: use-after-poison28  return 0;29}30