Blame SOURCES/0010-Fix-crashes-when-using-the-touch-option.patch

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