summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2006-02-01 05:03:04 (GMT)
committerH. Peter Anvin <hpa@zytor.com>2006-02-01 05:03:04 (GMT)
commit678414f3bf4733777a57d083a77289677e6ae35f (patch)
tree0ce3ebda6af89dda06125b4bd93b99f70f017f96
parenta6ea99d9a4ac66b2edc45812fe8fa7be445d2a3e (diff)
downloadmemhack-678414f3bf4733777a57d083a77289677e6ae35f.zip
memhack-678414f3bf4733777a57d083a77289677e6ae35f.tar.gz
memhack-678414f3bf4733777a57d083a77289677e6ae35f.tar.bz2
memhack-678414f3bf4733777a57d083a77289677e6ae35f.tar.xz
Compute the mmap range correctly
-rw-r--r--setmem.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/setmem.c b/setmem.c
index dac1d99..b44a015 100644
--- a/setmem.c
+++ b/setmem.c
@@ -112,9 +112,9 @@ int main(int argc, char *argv[])
page_mask = ~((uintptr_t)getpagesize()-1);
start = reg & page_mask;
- len = ((reg + size*(argc-optind) + page_mask) & page_mask) - start;
+ len = ((reg + size*(argc-optind) + ~page_mask) & page_mask) - start;
- map = mmap(NULL, len, PROT_WRITE, MAP_SHARED, fd, start);
+ map = mmap(NULL, len, PROT_READ|PROT_WRITE, MAP_SHARED, fd, start);
if ( map == MAP_FAILED ) {
perror("setmem:mmap");
exit(1);