mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-12 01:58:17 +00:00
libtokencap update proposal
- bcmp interception. - FreeBSD using default argument to get current pid for the mapping data gathering, getpid seems to cause some issues under certain conditions (getenv call).
This commit is contained in:
@ -115,7 +115,7 @@ static void __tokencap_load_mappings(void) {
|
|||||||
#elif defined __FreeBSD__ || defined __OpenBSD__ || defined __NetBSD__
|
#elif defined __FreeBSD__ || defined __OpenBSD__ || defined __NetBSD__
|
||||||
|
|
||||||
#if defined __FreeBSD__
|
#if defined __FreeBSD__
|
||||||
int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_VMMAP, getpid()};
|
int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_VMMAP, -1};
|
||||||
#elif defined __OpenBSD__
|
#elif defined __OpenBSD__
|
||||||
int mib[] = {CTL_KERN, KERN_PROC_VMMAP, getpid()};
|
int mib[] = {CTL_KERN, KERN_PROC_VMMAP, getpid()};
|
||||||
#elif defined __NetBSD__
|
#elif defined __NetBSD__
|
||||||
@ -134,9 +134,7 @@ static void __tokencap_load_mappings(void) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
buf = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
|
buf = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
|
||||||
if (!buf) {
|
if (buf == MAP_FAILED) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sysctl(mib, miblen, buf, &len, NULL, 0) == -1) {
|
if (sysctl(mib, miblen, buf, &len, NULL, 0) == -1) {
|
||||||
|
|
||||||
@ -354,6 +352,28 @@ int memcmp(const void* mem1, const void* mem2, size_t len) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#undef bcmp
|
||||||
|
|
||||||
|
int bcmp(const void* mem1, const void* mem2, size_t len) {
|
||||||
|
|
||||||
|
if (__tokencap_is_ro(mem1)) __tokencap_dump(mem1, len, 0);
|
||||||
|
if (__tokencap_is_ro(mem2)) __tokencap_dump(mem2, len, 0);
|
||||||
|
|
||||||
|
const char *strmem1 = (const char *)mem1;
|
||||||
|
const char *strmem2 = (const char *)mem2;
|
||||||
|
|
||||||
|
while (len--) {
|
||||||
|
|
||||||
|
int diff = *strmem1 ^ *strmem2;
|
||||||
|
if (diff != 0) return 1;
|
||||||
|
strmem1++;
|
||||||
|
strmem2++;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
#undef strstr
|
#undef strstr
|
||||||
|
|
||||||
char* strstr(const char* haystack, const char* needle) {
|
char* strstr(const char* haystack, const char* needle) {
|
||||||
|
@ -273,6 +273,9 @@ static void edit_params(u32 argc, char** argv) {
|
|||||||
cc_params[cc_par_cnt++] = "-fno-builtin-strcasecmp";
|
cc_params[cc_par_cnt++] = "-fno-builtin-strcasecmp";
|
||||||
cc_params[cc_par_cnt++] = "-fno-builtin-strncasecmp";
|
cc_params[cc_par_cnt++] = "-fno-builtin-strncasecmp";
|
||||||
cc_params[cc_par_cnt++] = "-fno-builtin-memcmp";
|
cc_params[cc_par_cnt++] = "-fno-builtin-memcmp";
|
||||||
|
cc_params[cc_par_cnt++] = "-fno-builtin-bcmp";
|
||||||
|
cc_params[cc_par_cnt++] = "-fno-builtin-strstr";
|
||||||
|
cc_params[cc_par_cnt++] = "-fno-builtin-strcasestr";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,6 +320,7 @@ static void edit_params(u32 argc, char** argv) {
|
|||||||
cc_params[cc_par_cnt++] = "-fno-builtin-strcasecmp";
|
cc_params[cc_par_cnt++] = "-fno-builtin-strcasecmp";
|
||||||
cc_params[cc_par_cnt++] = "-fno-builtin-strncasecmp";
|
cc_params[cc_par_cnt++] = "-fno-builtin-strncasecmp";
|
||||||
cc_params[cc_par_cnt++] = "-fno-builtin-memcmp";
|
cc_params[cc_par_cnt++] = "-fno-builtin-memcmp";
|
||||||
|
cc_params[cc_par_cnt++] = "-fno-builtin-bcmp";
|
||||||
cc_params[cc_par_cnt++] = "-fno-builtin-strstr";
|
cc_params[cc_par_cnt++] = "-fno-builtin-strstr";
|
||||||
cc_params[cc_par_cnt++] = "-fno-builtin-strcasestr";
|
cc_params[cc_par_cnt++] = "-fno-builtin-strcasestr";
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user