bd72f1
From a47463a72864a76b0557468daf83741632ea4d72 Mon Sep 17 00:00:00 2001
bd72f1
From: Patrick Mansfield <patrick.mansfield@cpacketnetworks.com>
bd72f1
Date: Mon, 30 Sep 2019 15:59:53 -0700
bd72f1
Subject: [PATCH] Fix crashes when using the "--touch" option.
bd72f1
bd72f1
Fix memory to be mapped read/write, so that the "touch" option can write to it.
bd72f1
bd72f1
Signed-off-by: Patrick Mansfield <patrick.mansfield@cpacketnetworks.com>
bd72f1
---
bd72f1
 shm.c | 6 +++---
bd72f1
 1 file changed, 3 insertions(+), 3 deletions(-)
bd72f1
bd72f1
diff --git a/shm.c b/shm.c
bd72f1
index 260eeff..fb592ed 100644
bd72f1
--- a/shm.c
bd72f1
+++ b/shm.c
bd72f1
@@ -119,7 +119,7 @@ void attach_sysvshm(char *name, char *opt)
bd72f1
 		shmlen = s.shm_segsz;
bd72f1
 	}
bd72f1
 
bd72f1
-	shmptr = shmat(shmfd, NULL, SHM_RDONLY);
bd72f1
+	shmptr = shmat(shmfd, NULL, 0);
bd72f1
 	if (shmptr == (void*)-1)
bd72f1
 		err("shmat");
bd72f1
 	shmptr += shmoffset;
bd72f1
@@ -134,7 +134,7 @@ void attach_shared(char *name, char *opt)
bd72f1
 {
bd72f1
 	struct stat64 st;
bd72f1
 
bd72f1
-	shmfd = open(name, O_RDONLY);
bd72f1
+	shmfd = open(name, O_RDWR);
bd72f1
 	if (shmfd < 0) {
bd72f1
 		errno = 0;
bd72f1
 		if (shmlen == 0)
bd72f1
@@ -160,7 +160,7 @@ void attach_shared(char *name, char *opt)
bd72f1
 
bd72f1
 	/* RED-PEN For shmlen > address space may need to map in pieces.
bd72f1
 	   Left for some poor 32bit soul. */
bd72f1
-	shmptr = mmap64(NULL, shmlen, PROT_READ, MAP_SHARED, shmfd, shmoffset);
bd72f1
+	shmptr = mmap64(NULL, shmlen, PROT_READ | PROT_WRITE, MAP_SHARED, shmfd, shmoffset);
bd72f1
 	if (shmptr == (char*)-1)
bd72f1
 		err("shm mmap");
bd72f1
 
bd72f1
-- 
bd72f1
2.7.5
bd72f1