diff options
author | hexcoder- <heiko@hexco.de> | 2019-10-27 07:27:48 +0100 |
---|---|---|
committer | hexcoder- <heiko@hexco.de> | 2019-10-27 07:27:48 +0100 |
commit | 74df3e24913a882d22a39a3ea32ec7288921f0e0 (patch) | |
tree | 4ef4f0e2569791af14dabf11dfc6056361bb1312 /libtokencap/libtokencap.so.c | |
parent | 8e41a59e2e00447a97208ed7cf0d163a3d47066b (diff) | |
download | afl++-74df3e24913a882d22a39a3ea32ec7288921f0e0.tar.gz |
WIP for NetBSD port, iteration has an unknown problem causing a seg fault
Diffstat (limited to 'libtokencap/libtokencap.so.c')
-rw-r--r-- | libtokencap/libtokencap.so.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/libtokencap/libtokencap.so.c b/libtokencap/libtokencap.so.c index d33de8a4..7ed231fe 100644 --- a/libtokencap/libtokencap.so.c +++ b/libtokencap/libtokencap.so.c @@ -27,14 +27,14 @@ #include "../types.h" #include "../config.h" -#if !defined __linux__ && !defined __APPLE__ && !defined __FreeBSD__ && !defined __OpenBSD__ +#if !defined __linux__ && !defined __APPLE__ && !defined __FreeBSD__ && !defined __OpenBSD__ && !defined __NetBSD__ # error "Sorry, this library is unsupported in this platform for now!" -#endif /* !__linux__ && !__APPLE__ && ! __FreeBSD__ */ +#endif /* !__linux__ && !__APPLE__ && ! __FreeBSD__ && ! __OpenBSD__ && !__NetBSD__*/ #if defined __APPLE__ # include <mach/vm_map.h> # include <mach/mach_init.h> -#elif defined __FreeBSD__ || defined __OpenBSD__ +#elif defined __FreeBSD__ || defined __OpenBSD__ || defined __NetBSD__ # include <sys/types.h> # include <sys/sysctl.h> # include <sys/user.h> @@ -111,12 +111,14 @@ static void __tokencap_load_mappings(void) { } } -#elif defined __FreeBSD__ || defined __OpenBSD__ +#elif defined __FreeBSD__ || defined __OpenBSD__ || defined __NetBSD__ #if defined __FreeBSD__ int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_VMMAP, getpid()}; #elif defined __OpenBSD__ int mib[] = {CTL_KERN, KERN_PROC_VMMAP, getpid()}; +#elif defined __NetBSD__ + int mib[] = {CTL_VM, VM_PROC, VM_PROC_MAP, getpid(), sizeof(struct kinfo_vmentry)}; #endif char *buf, *low, *high; size_t miblen = sizeof(mib)/sizeof(mib[0]); @@ -124,7 +126,7 @@ static void __tokencap_load_mappings(void) { if (sysctl(mib, miblen, NULL, &len, NULL, 0) == -1) return; -#if defined __FreeBSD__ +#if defined __FreeBSD__ || defined __NetBSD__ len = len * 4 / 3; #elif defined __OpenBSD__ len -= len % sizeof(struct kinfo_vmentry); @@ -150,11 +152,15 @@ static void __tokencap_load_mappings(void) { while (low < high) { struct kinfo_vmentry *region = (struct kinfo_vmentry *)low; -#if defined __FreeBSD__ +#if defined __FreeBSD__ || defined __NetBSD__ +#if defined __FreeBSD__ size_t size = region->kve_structsize; if (size == 0) break; +#elif defined __NetBSD__ + size_t size = sizeof (*region); +#endif /* We go through the whole mapping of the process and track read-only addresses */ if ((region->kve_protection & KVME_PROT_READ) && |