Skip to content

Commit

Permalink
Fix crashes when using the "--touch" option.
Browse files Browse the repository at this point in the history
Fix memory to be mapped read/write, so that the "touch" option can write to it.

Signed-off-by: Patrick Mansfield <patrick.mansfield@cpacketnetworks.com>
  • Loading branch information
patman-cp authored and andikleen committed Oct 16, 2019
1 parent 6179276 commit a47463a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions shm.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void attach_sysvshm(char *name, char *opt)
shmlen = s.shm_segsz;
}

shmptr = shmat(shmfd, NULL, SHM_RDONLY);
shmptr = shmat(shmfd, NULL, 0);
if (shmptr == (void*)-1)
err("shmat");
shmptr += shmoffset;
Expand All @@ -134,7 +134,7 @@ void attach_shared(char *name, char *opt)
{
struct stat64 st;

shmfd = open(name, O_RDONLY);
shmfd = open(name, O_RDWR);
if (shmfd < 0) {
errno = 0;
if (shmlen == 0)
Expand All @@ -160,7 +160,7 @@ void attach_shared(char *name, char *opt)

/* RED-PEN For shmlen > address space may need to map in pieces.
Left for some poor 32bit soul. */
shmptr = mmap64(NULL, shmlen, PROT_READ, MAP_SHARED, shmfd, shmoffset);
shmptr = mmap64(NULL, shmlen, PROT_READ | PROT_WRITE, MAP_SHARED, shmfd, shmoffset);
if (shmptr == (char*)-1)
err("shm mmap");

Expand Down

0 comments on commit a47463a

Please sign in to comment.