1 // Test that small memcpy works correctly.
3 // RUN: %clangxx_asan %s -o %t
4 // RUN: not %run %t 8 24 2>&1 | FileCheck %s --check-prefix=CHECK
5 // RUN: not %run %t 16 32 2>&1 | FileCheck %s --check-prefix=CHECK
6 // RUN: not %run %t 24 40 2>&1 | FileCheck %s --check-prefix=CHECK
7 // RUN: not %run %t 32 48 2>&1 | FileCheck %s --check-prefix=CHECK
8 // RUN: not %run %t 40 56 2>&1 | FileCheck %s --check-prefix=CHECK
9 // RUN: not %run %t 48 64 2>&1 | FileCheck %s --check-prefix=CHECK
10 // REQUIRES: shadow-scale-3
16 #include <sanitizer/asan_interface.h>
18 int main(int argc
, char **argv
) {
20 size_t poison_from
= atoi(argv
[1]);
21 size_t poison_to
= atoi(argv
[2]);
22 assert(poison_from
<= poison_to
);
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-poison