Hi!

I noticed that the devmem applet maps two consecutive pages of memory in order 
to allow access to a (non-aligned) object that spans two pages. This is a 
problem if we are working with the last page of memory because the next page 
would wrap around to the first page of memory.

This patch makes devmem map only a single page if it is at the end of the 
memory address space.
-- 
[email protected] (040-5240412)
--- busybox-1.16.0/miscutils/devmem.c	2010-01-25 02:59:38.000000000 +0200
+++ busybox-1.16.0-devmem/miscutils/devmem.c	2010-03-26 11:57:18.000000000 +0200
@@ -58,7 +58,8 @@ int devmem_main(int argc UNUSED_PARAM, c
 
 	fd = xopen("/dev/mem", argv[3] ? (O_RDWR | O_SYNC) : (O_RDONLY | O_SYNC));
 	map_base = mmap(NULL,
-			page_size * 2 /* in case value spans page */,
+			(target >= (~0 & ~(off_t)(page_size - 1))) ? /* Last page? */
+			page_size : page_size * 2, /* in case value spans page */
 			argv[3] ? (PROT_READ | PROT_WRITE) : PROT_READ,
 			MAP_SHARED,
 			fd,
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to