Skip to content

Commit

Permalink
Add further memset/memcpy test
Browse files Browse the repository at this point in the history
  • Loading branch information
mrstanb committed Oct 1, 2023
1 parent 3027910 commit 62b20a2
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/regression/77-mem-oob/09-memset-memcpy-addr-offs.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// PARAM: --set ana.activated[+] memOutOfBounds --enable ana.int.interval --disable warn.info
// TODO: The "--disable warn.info" part is a temporary fix and needs to be removed once the MacOS CI job is fixed
#include <stdlib.h>
#include <string.h>

int main(int argc, char const *argv[]) {
int *a = malloc(10 * sizeof(int)); //Size is 40 bytes, assuming a 4-byte int
int *b = malloc(15 * sizeof(int)); //Size is 60 bytes, assuming a 4-byte int

memset(a, 0, 40); //NOWARN
memcpy(a, b, 40); //NOWARN

a += 3;

memset(a, 0, 40); //WARN
memcpy(a, b, 40); //WARN

memset(a, 0, 37); //NOWARN
memcpy(a, b, 37); //NOWARN
}

0 comments on commit 62b20a2

Please sign in to comment.