]> git.proxmox.com Git - rustc.git/blame - src/compiler-rt/test/asan/TestCases/Windows/intercept_memcpy.cc
New upstream version 1.19.0+dfsg3
[rustc.git] / src / compiler-rt / test / asan / TestCases / Windows / intercept_memcpy.cc
CommitLineData
92a42be0
SL
1// RUN: %clang_cl_asan -O0 %s -Fe%t
2// RUN: not %run %t 2>&1 | FileCheck %s
3
4#include <stdio.h>
5#include <string.h>
6
7void call_memcpy(void* (*f)(void *, const void *, size_t),
8 void *a, const void *b, size_t c) {
9 f(a, b, c);
10}
11
12int main() {
13 char buff1[6] = "Hello", buff2[5];
14
15 call_memcpy(&memcpy, buff2, buff1, 5);
16 if (buff1[2] != buff2[2])
17 return 2;
18 printf("Initial test OK\n");
19 fflush(0);
20// CHECK: Initial test OK
21
22 call_memcpy(&memcpy, buff2, buff1, 6);
23// CHECK: AddressSanitizer: stack-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
24// CHECK: WRITE of size 6 at [[ADDR]] thread T0
7cac9316
XL
25// CHECK-NEXT: __asan_{{.*}}mem{{.*}}
26// CHECK-NEXT: call_mem{{.*}}
92a42be0
SL
27// CHECK-NEXT: main {{.*}}intercept_memcpy.cc:[[@LINE-5]]
28// CHECK: Address [[ADDR]] is located in stack of thread T0 at offset {{.*}} in frame
29// CHECK-NEXT: #0 {{.*}} main
30// CHECK: 'buff2' <== Memory access at offset {{.*}} overflows this variable
31}