-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathtest_nearheap.c
48 lines (37 loc) · 934 Bytes
/
test_nearheap.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
45
46
47
48
#define _DEFAULT_SOURCE
#include <stdio.h>
#include <sys/auxv.h>
#include <unistd.h>
#include <stdlib.h>
#include "debugmenot.h"
#include "test_nearheap.h"
static int detect(void)
{
/* GDB relocates the heap to the end of the bss section */
static unsigned char bss;
unsigned char *probe = malloc(0x10);
if (probe - &bss > 0x20000) {
return RESULT_NO;
} else {
return RESULT_YES;
}
}
static int cleanup(void)
{
/* Nothing to be done */
return 0;
}
int register_test_nearheap(struct test_chain *all_tests, unsigned int test_bmp)
{
struct test_chain *test;
if (!(test_bmp & (1 << TEST_ID_NEARHEAP)))
return 0;
test = test_chain_alloc_new(all_tests);
if (!test)
return 1 << TEST_ID_NEARHEAP;
test->detect = detect;
test->description = TEST_DESC_NEARHEAP;
test->name = TEST_NAME_NEARHEAP;
test->cleanup = cleanup;
return 0;
}