summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2006-01-28 02:03:16 (GMT)
committerH. Peter Anvin <hpa@zytor.com>2006-01-28 02:03:16 (GMT)
commita6ea99d9a4ac66b2edc45812fe8fa7be445d2a3e (patch)
tree3ec2c7aeab87c7fbfc78016862b4a73f03cb1680
parentdd620f4881e5cb3fc8b720dc3772f94df8999771 (diff)
downloadmemhack-a6ea99d9a4ac66b2edc45812fe8fa7be445d2a3e.zip
memhack-a6ea99d9a4ac66b2edc45812fe8fa7be445d2a3e.tar.gz
memhack-a6ea99d9a4ac66b2edc45812fe8fa7be445d2a3e.tar.bz2
memhack-a6ea99d9a4ac66b2edc45812fe8fa7be445d2a3e.tar.xz
Fix computation of mmap size in setmem
-rw-r--r--Makefile2
-rw-r--r--setmem.c4
2 files changed, 3 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 6be1151..ba5ec51 100644
--- a/Makefile
+++ b/Makefile
@@ -17,7 +17,7 @@
#
CC = gcc -Wall
-CFLAGS = -g -O2 -fomit-frame-pointer -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
+CFLAGS = -g -O2 -fomit-frame-pointer -D_GNU_SOURCE -D_LARGE_FILE -D_FILE_OFFSET_BITS=64
LDFLAGS =
BIN = getmem setmem getio setio
diff --git a/setmem.c b/setmem.c
index d563655..dac1d99 100644
--- a/setmem.c
+++ b/setmem.c
@@ -96,7 +96,7 @@ int main(int argc, char *argv[])
}
}
- if ( optind > argc-2 ) {
+ if ( argc-optind < 1 ) {
/* Should have at least two arguments */
usage();
exit(127);
@@ -112,7 +112,7 @@ int main(int argc, char *argv[])
page_mask = ~((uintptr_t)getpagesize()-1);
start = reg & page_mask;
- len = ((reg + size*(argc-optind)) & page_mask) - start;
+ len = ((reg + size*(argc-optind) + page_mask) & page_mask) - start;
map = mmap(NULL, len, PROT_WRITE, MAP_SHARED, fd, start);
if ( map == MAP_FAILED ) {