| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
#undef memmove |
| 7 |
|
| 8 |
#include <proof_helpers/nondet.h> |
| 9 |
#include <stdint.h> |
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 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 |
} |