| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
#undef memmove |
| 17 |
|
| 18 |
#include <cbmc_proof/nondet.h> |
| 19 |
#include <stdint.h> |
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
void *memmove_impl(void *dest, const void *src, size_t n) { |
| 28 |
__CPROVER_HIDE:; |
| 29 |
__CPROVER_precondition(src != NULL && __CPROVER_r_ok(src, n), "memmove source region readable"); |
| 30 |
__CPROVER_precondition(dest != NULL && __CPROVER_w_ok(dest, n), "memmove destination region writeable"); |
| 31 |
|
| 32 |
if (n > 0) { |
| 33 |
size_t idx; |
| 34 |
__CPROVER_assume(idx < n); |
| 35 |
((uint8_t *)dest)[idx] = nondet_uint8_t(); |
| 36 |
} |
| 37 |
|
| 38 |
return dest; |
| 39 |
} |
| 40 |
|
| 41 |
void *memmove(void *dest, const void *src, size_t n) { |
| 42 |
__CPROVER_HIDE:; |
| 43 |
return memmove_impl(dest, src, n); |
| 44 |
} |
| 45 |
|
| 46 |
void *__builtin___memmove_chk(void *dest, const void *src, size_t n, size_t size) { |
| 47 |
__CPROVER_HIDE:; |
| 48 |
(void)size; |
| 49 |
return memmove_impl(dest, src, n); |
| 50 |
} |