Add two tests to check that uninitialized read are zeroed
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__':
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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