aboutsummaryrefslogtreecommitdiff
path: root/src/afl-sharedmem.c
diff options
context:
space:
mode:
authorAndrea Fioraldi <andreafioraldi@gmail.com>2020-01-30 22:54:23 +0100
committerGitHub <noreply@github.com>2020-01-30 22:54:23 +0100
commit19ebdf31b999223e4965f701077f9af9d550e386 (patch)
tree9c6d27d58d0606d59725ef46766eb1961e908d31 /src/afl-sharedmem.c
parentb050c1158398dd07e25a6cd65234da84e5656fa6 (diff)
parent6e9fce1c2d654c92dbf8e6b8cc21a88d8cba9496 (diff)
downloadafl++-19ebdf31b999223e4965f701077f9af9d550e386.tar.gz
Merge pull request #178 from vanhauser-thc/CmpLog
Cmp log
Diffstat (limited to 'src/afl-sharedmem.c')
-rw-r--r--src/afl-sharedmem.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/afl-sharedmem.c b/src/afl-sharedmem.c
index 04fcaa1c..3f552881 100644
--- a/src/afl-sharedmem.c
+++ b/src/afl-sharedmem.c
@@ -35,6 +35,7 @@
#include "alloc-inl.h"
#include "hash.h"
#include "sharedmem.h"
+#include "cmplog.h"
#include <stdio.h>
#include <unistd.h>
@@ -68,8 +69,12 @@ char g_shm_file_path[L_tmpnam];
/* ========================================= */
#else
static s32 shm_id; /* ID of the SHM region */
+static s32 cmplog_shm_id;
#endif
+int cmplog_mode;
+struct cmp_map *cmp_map;
+
/* Get rid of shared memory (atexit handler). */
void remove_shm(void) {
@@ -91,6 +96,7 @@ void remove_shm(void) {
#else
shmctl(shm_id, IPC_RMID, NULL);
+ if (cmplog_mode) shmctl(cmplog_shm_id, IPC_RMID, NULL);
#endif
}
@@ -149,6 +155,15 @@ void setup_shm(unsigned char dumb_mode) {
if (shm_id < 0) PFATAL("shmget() failed");
+ if (cmplog_mode) {
+
+ cmplog_shm_id = shmget(IPC_PRIVATE, sizeof(struct cmp_map),
+ IPC_CREAT | IPC_EXCL | 0600);
+
+ if (cmplog_shm_id < 0) PFATAL("shmget() failed");
+
+ }
+
atexit(remove_shm);
shm_str = alloc_printf("%d", shm_id);
@@ -162,8 +177,20 @@ void setup_shm(unsigned char dumb_mode) {
ck_free(shm_str);
+ if (cmplog_mode) {
+
+ shm_str = alloc_printf("%d", cmplog_shm_id);
+
+ if (!dumb_mode) setenv(CMPLOG_SHM_ENV_VAR, shm_str, 1);
+
+ ck_free(shm_str);
+
+ }
+
trace_bits = shmat(shm_id, NULL, 0);
+ if (cmplog_mode) cmp_map = shmat(cmplog_shm_id, NULL, 0);
+
if (!trace_bits) PFATAL("shmat() failed");
#endif