Debian Codegraph @

crt/aws-c-common/verification/cbmc/stubs/memset_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 memset
7
8 #include <proof_helpers/nondet.h>
9 #include <stddef.h>
10
11 /**
12 * Override the version of memset used by CBMC. Users may not want to pay
13 * for the cost of performing the computation of memset in proofs. In that
14 * case, this stub at least checks for the preconditions and make sure to
15 * havoc all elements pointed by *s up to n.
16 */
17 void *memset_impl(void *s, int c, size_t n) {
18 __CPROVER_precondition(__CPROVER_w_ok(s, n), "memset destination region writeable");
19 if (n > 0) {
20 size_t index;
21 __CPROVER_assume(index < n);
22 ((uint8_t *)s)[index] = nondet_uint8_t();
23 }
24 return s;
25 }
26
27 void *memset(void *s, int c, size_t n) {
28 return memset_impl(s, c, n);
29 }
30
31 void *__builtin___memset_chk(void *s, int c, size_t n, size_t os) {
32 (void)os;
33 return memset_impl(s, c, n);
34 }