introduce pointer dereference validation method
This commit is contained in:
@@ -114,3 +114,15 @@ unsigned getSLEB128Size(int64_t Value)
|
|||||||
|
|
||||||
return Size;
|
return Size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
bool is_pointer_valid(void *p)
|
||||||
|
{
|
||||||
|
/* get the page size */
|
||||||
|
size_t page_size = sysconf(_SC_PAGESIZE);
|
||||||
|
/* find the address of the page that contains p */
|
||||||
|
void *base = (void *)((((size_t)p) / page_size) * page_size);
|
||||||
|
/* call msync, if it returns non-zero, return false */
|
||||||
|
return msync(base, page_size, MS_ASYNC) == 0;
|
||||||
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
#define USE_LIBUNWIND
|
#define USE_LIBUNWIND
|
||||||
|
|
||||||
@@ -20,5 +21,6 @@
|
|||||||
|
|
||||||
int32_t decode_sleb128(uint8_t *sleb128);
|
int32_t decode_sleb128(uint8_t *sleb128);
|
||||||
uint32_t decode_uleb128(uint8_t *uleb128);
|
uint32_t decode_uleb128(uint8_t *uleb128);
|
||||||
|
bool is_pointer_valid(void *p);
|
||||||
|
|
||||||
#endif // __PST_COMMON_H__
|
#endif // __PST_COMMON_H__
|
||||||
|
|||||||
Reference in New Issue
Block a user