Debian Codegraph @

crt/aws-c-common/verification/cbmc/stubs/memmove_override_havoc.c

raw symbols SCIP
1 /**
2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 * SPDX-License-Identifier: Apache-2.0.
4 */
5
6 #undef memmove
7
8 #include <proof_helpers/nondet.h>
9 #include <stdint.h>
10
11 /**
12 * Override the version of memmove used by CBMC. Users may not want to pay
13 * for the cost of performing the computation of memmove in proofs. In that
14 * case, this stub at least checks for the preconditions and make sure to
15 * havoc all elements pointed by *dest up to n.
16 */
17 void *memmove_impl(void *dest, const void *src, size_t n) {
18 __CPROVER_precondition(src != NULL && __CPROVER_r_ok(src, n), "memmove source region readable");
19 __CPROVER_precondition(dest != NULL && __CPROVER_w_ok(dest, n), "memmove destination region writeable");
20
21 if (n > 0) {
22 size_t index;
23 __CPROVER_assume(index < n);
24 ((uint8_t *)dest)[index] = nondet_uint8_t();
25 }
26
27 return dest;
28 }
29
30 void *memmove(void *dest, const void *src, size_t n) {
31 return memmove_impl(dest, src, n);
32 }
33
34 void *__builtin___memmove_chk(void *dest, const void *src, size_t n, size_t size) {
35 (void)size;
36 return memmove_impl(dest, src, n);
37 }