about summary refs log tree commit diff
path: root/libtokencap/libtokencap.so.c
diff options
context:
space:
mode:
authorDavid Carlier <dcarlier@afilias.info>2019-11-07 11:52:04 +0000
committerDavid Carlier <dcarlier@afilias.info>2019-11-07 11:52:04 +0000
commitb92da08ae8cbe8795e39c981525548bca0ce5607 (patch)
treee4c9600935c77e590f62af969da6cce4ccba3179 /libtokencap/libtokencap.so.c
parent7b82ef22bea26b7f867cff21de2866b74f4f9dc1 (diff)
parent499f078c3759a22dd5cfd81d2271969f19b75090 (diff)
downloadafl++-b92da08ae8cbe8795e39c981525548bca0ce5607.tar.gz
Taking in account last changes
Diffstat (limited to 'libtokencap/libtokencap.so.c')
-rw-r--r--libtokencap/libtokencap.so.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/libtokencap/libtokencap.so.c b/libtokencap/libtokencap.so.c
index 7495180d..467be05b 100644
--- a/libtokencap/libtokencap.so.c
+++ b/libtokencap/libtokencap.so.c
@@ -51,6 +51,7 @@ static struct mapping { void *st, *en; } __tokencap_ro[MAX_MAPPINGS];
 static u32   __tokencap_ro_cnt;
 static u8    __tokencap_ro_loaded;
 static int __tokencap_out_file = -1;
+static pid_t __tokencap_pid = -1;
 
 /* Identify read-only regions in memory. Only parameters that fall into these
    ranges are worth dumping when passed to strcmp() and so on. Read-write
@@ -115,11 +116,11 @@ static void __tokencap_load_mappings(void) {
 #elif defined __FreeBSD__ || defined __OpenBSD__ || defined __NetBSD__
 
 #if defined __FreeBSD__
-  int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_VMMAP, -1};
+  int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_VMMAP, __tokencap_pid};
 #elif defined __OpenBSD__
-  int mib[] = {CTL_KERN, KERN_PROC_VMMAP, getpid()};
+  int mib[] = {CTL_KERN, KERN_PROC_VMMAP, __tokencap_pid};
 #elif defined __NetBSD__
-  int mib[] = {CTL_VM, VM_PROC, VM_PROC_MAP, getpid(), sizeof(struct kinfo_vmentry)};
+  int mib[] = {CTL_VM, VM_PROC, VM_PROC_MAP, __tokencap_pid, sizeof(struct kinfo_vmentry)};
 #endif
   char *buf, *low, *high;
   size_t miblen = sizeof(mib)/sizeof(mib[0]);
@@ -431,6 +432,7 @@ __attribute__((constructor)) void __tokencap_init(void) {
   u8* fn = getenv("AFL_TOKEN_FILE");
   if (fn) __tokencap_out_file = open(fn, O_RDWR | O_CREAT | O_APPEND, 0655);
   if (__tokencap_out_file == -1) __tokencap_out_file = STDERR_FILENO;
+  __tokencap_pid = getpid();
 
 }