about summary refs log tree commit diff homepage
path: root/test/Runtime/FreeStanding/memcpy_chk_err.c
blob: 997499ec1325902e877c333a09adf6c2f151aa63 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// This test checks that __memcpy_chk find the kind of errors it was
// designed to find

// On FreeBSD, a direct call to memcpy is emitted instead of to __memcpy_chk
// REQUIRES: not-freebsd

// RUN: %clang %s -emit-llvm -O2 -g -c -D_FORTIFY_SOURCE=1 -o %t2.bc
// RUN: rm -rf %t.klee-out
// RUN: %klee --output-dir=%t.klee-out %t2.bc

// RUN: FileCheck --check-prefix=CHECK-BC --input-file %t.klee-out/assembly.ll %s
// CHECK-BC: @__memcpy_chk

// RUN: test -f %t.klee-out/test000001.ptr.err
// RUN: FileCheck --input-file %t.klee-out/test000001.ptr.err %s
// CHECK: memcpy overflow

#include "klee/klee.h"

#include <assert.h>
#include <stdlib.h>
#include <string.h>

int main() {
  char d[5];
  char *s = "1234567890";

  memcpy(d, s, 10);
}