Skip to content

fix memcpy overlap check #3483

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CORE
main.c
memcpy1.c
--bounds-check --pointer-check
^EXIT=10$
^SIGNAL=0$
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CORE
main.c
memcpy2.c

^EXIT=0$
^SIGNAL=0$
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CORE
main.c
memcpy3.c

^EXIT=0$
^SIGNAL=0$
Expand Down
18 changes: 18 additions & 0 deletions regression/cbmc-library/memcpy-02/memcpy4.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <string.h>

int main()
{
char bufferA[10], bufferB[10];

// ok
memcpy(bufferA, bufferB, 10);

// not ok, overlap, should use memmove
memcpy(bufferA, bufferA + 1, 9);

// ok, no overlap
memcpy(bufferA, bufferA + 5, 5);

// out of bounds
memcpy(bufferA + 1, bufferB, 10);
}
13 changes: 13 additions & 0 deletions regression/cbmc-library/memcpy-02/memcpy4.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
CORE
memcpy4.c
--pointer-check
^EXIT=10$
^SIGNAL=0$
^\[.*] line 8 memcpy src/dst overlap: SUCCESS$
^\[.*] line 11 memcpy src/dst overlap: FAILURE$
^\[.*] line 14 memcpy src/dst overlap: SUCCESS$
^\[.*] line 17 memcpy src/dst overlap: SUCCESS$
^\[.*] line 17 memcpy destination region writeable: FAILURE$
^VERIFICATION FAILED$
--
^warning: ignoring
1 change: 1 addition & 0 deletions scripts/delete_failing_smt2_solver_tests
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ rm havoc_object1/test.desc
rm hex_trace/test.desc
rm integer-assignments1/test.desc
rm little-endian-array1/test.desc
rm memcpy/memcpy4.desc
rm memory_allocation1/test.desc
rm memset1/test.desc
rm mm_io1/test.desc
Expand Down
Loading