svn commit: r272374 - user/marcel/mkimg

Marcel Moolenaar marcel at FreeBSD.org
Wed Oct 1 16:47:14 UTC 2014


Author: marcel
Date: Wed Oct  1 16:47:14 2014
New Revision: 272374
URL: https://svnweb.freebsd.org/changeset/base/272374

Log:
  Make sure to widen secsz from size_t to off_t when using it as a mask.
  On 32-bit machines this would other wise mask off the upper 32-bits
  of the 64-bit file offset.

Modified:
  user/marcel/mkimg/image.c

Modified: user/marcel/mkimg/image.c
==============================================================================
--- user/marcel/mkimg/image.c	Wed Oct  1 16:18:59 2014	(r272373)
+++ user/marcel/mkimg/image.c	Wed Oct  1 16:47:14 2014	(r272374)
@@ -418,7 +418,7 @@ image_copyin_mapped(lba_t blk, int fd, u
 
 		if (cur == hole && data > hole) {
 			hole = pos;
-			pos = data & ~(secsz - 1);
+			pos = data & ~((uint64_t)secsz - 1);
 
 			blk += (pos - hole) / secsz;
 			error = image_chunk_skipto(blk);
@@ -427,7 +427,7 @@ image_copyin_mapped(lba_t blk, int fd, u
 			cur = data;
 		} else if (cur == data && hole > data) {
 			data = pos;
-			pos = (hole + secsz - 1) & ~(secsz - 1);
+			pos = (hole + secsz - 1) & ~((uint64_t)secsz - 1);
 
 			while (data < pos) {
 				sz = (pos - data > (off_t)iosz)


More information about the svn-src-user mailing list