From fe85116891b3317e1e99a8ee534467bae5eea77e Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Fri, 24 Aug 2018 05:02:00 -0400 Subject: [PATCH] add uninitialized allocator tests --- test/simple-memory-corruption/Makefile | 3 +++ test/simple-memory-corruption/uninitialized_free.c | 7 +++++++ .../uninitialized_malloc_usable_size.c | 7 +++++++ test/simple-memory-corruption/uninitialized_realloc.c | 10 ++++++++++ 4 files changed, 27 insertions(+) create mode 100644 test/simple-memory-corruption/uninitialized_free.c create mode 100644 test/simple-memory-corruption/uninitialized_malloc_usable_size.c create mode 100644 test/simple-memory-corruption/uninitialized_realloc.c diff --git a/test/simple-memory-corruption/Makefile b/test/simple-memory-corruption/Makefile index e638996..62d6653 100644 --- a/test/simple-memory-corruption/Makefile +++ b/test/simple-memory-corruption/Makefile @@ -12,3 +12,6 @@ all: \ invalid_free_protected \ invalid_free_unprotected \ invalid_free_small_region \ + uninitialized_free \ + uninitialized_realloc \ + uninitialized_malloc_usable_size \ diff --git a/test/simple-memory-corruption/uninitialized_free.c b/test/simple-memory-corruption/uninitialized_free.c new file mode 100644 index 0000000..0028be9 --- /dev/null +++ b/test/simple-memory-corruption/uninitialized_free.c @@ -0,0 +1,7 @@ +#include + +__attribute__((optimize(0))) +int main(void) { + free((void *)1); + return 0; +} diff --git a/test/simple-memory-corruption/uninitialized_malloc_usable_size.c b/test/simple-memory-corruption/uninitialized_malloc_usable_size.c new file mode 100644 index 0000000..3b2924f --- /dev/null +++ b/test/simple-memory-corruption/uninitialized_malloc_usable_size.c @@ -0,0 +1,7 @@ +#include + +__attribute__((optimize(0))) +int main(void) { + malloc_usable_size((void *)1); + return 0; +} diff --git a/test/simple-memory-corruption/uninitialized_realloc.c b/test/simple-memory-corruption/uninitialized_realloc.c new file mode 100644 index 0000000..e0dc09a --- /dev/null +++ b/test/simple-memory-corruption/uninitialized_realloc.c @@ -0,0 +1,10 @@ +#include + +__attribute__((optimize(0))) +int main(void) { + void *p = realloc((void *)1, 16); + if (!p) { + return 1; + } + return 0; +}