mirror of
https://github.com/GrapheneOS/hardened_malloc.git
synced 2024-12-18 04:14:23 -05:00
Add two tests to check that uninitialized read are zeroed
This commit is contained in:
parent
3696f071a4
commit
5f59ee3935
@ -34,6 +34,8 @@ EXECUTABLES := \
|
||||
invalid_free_unprotected \
|
||||
invalid_free_small_region \
|
||||
invalid_free_small_region_far \
|
||||
uninitialized_read_small \
|
||||
uninitialized_read_large \
|
||||
uninitialized_free \
|
||||
uninitialized_realloc \
|
||||
uninitialized_malloc_usable_size \
|
||||
|
@ -211,6 +211,15 @@ class TestSimpleMemoryCorruption(unittest.TestCase):
|
||||
"impossibly_large_malloc")
|
||||
self.assertEqual(returncode, 0)
|
||||
|
||||
def test_uninitialized_read_small(self):
|
||||
_stdout, stderr, returncode = self.run_test(
|
||||
"uninitialized_read_small")
|
||||
self.assertEqual(returncode, 0)
|
||||
|
||||
def test_uninitialized_read_large(self):
|
||||
_stdout, stderr, returncode = self.run_test(
|
||||
"uninitialized_read_large")
|
||||
self.assertEqual(returncode, 0)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
14
test/simple-memory-corruption/uninitialized_read_large.c
Normal file
14
test/simple-memory-corruption/uninitialized_read_large.c
Normal file
@ -0,0 +1,14 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "../test_util.h"
|
||||
|
||||
OPTNONE int main(void) {
|
||||
char *p = malloc(128 * 1024);
|
||||
for (unsigned i = 0; i < 8; i++) {
|
||||
if (p[i] != 0) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
free(p);
|
||||
return 0;
|
||||
}
|
14
test/simple-memory-corruption/uninitialized_read_small.c
Normal file
14
test/simple-memory-corruption/uninitialized_read_small.c
Normal file
@ -0,0 +1,14 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "../test_util.h"
|
||||
|
||||
OPTNONE int main(void) {
|
||||
char *p = malloc(8);
|
||||
for (unsigned i = 0; i < 8; i++) {
|
||||
if (p[i] != 0) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
free(p);
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user