-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfuzz_memory.c
44 lines (39 loc) · 836 Bytes
/
fuzz_memory.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "ifuzz.h"
static char *ptr_list[MAX_HEAP_STRINGS];
void
rfree ()
{
int ix = 0;
while (ptr_list[ix] && (ix < MAX_HEAP_STRINGS))
{
free (ptr_list[ix]);
ptr_list[ix++] = NULL;
}
return;
}
/* malloc and register some heap space */
void *
rmalloc (size_t size)
{
int ix = 0;
void *ptr;
if (!size)
return NULL;
if (!(ptr = malloc (size)))
{
fprintf (stderr, "FATAL ERROR: OUT OF MEMORY IN RMALLOC\n");
exit (-1);
}
while (ptr_list[ix] && (ix < MAX_HEAP_STRINGS))
ix++;
if (ix < MAX_HEAP_STRINGS)
ptr_list[ix] = ptr;
else
{
fprintf (stderr, "FATAL ERROR: TOO MANY HEAP BASED FUZZ STRINGS.\n");
fprintf (stderr,
"TRY ADJUSTING 'MAX_HEAP_STRINGS' OR JUST DON'T BE SUCH A MANIAC ALL THE TIME\n");
exit (-1);
}
return ptr;
}