svn commit: r266514 - head/usr.bin/mkimg

Marcel Moolenaar marcel at FreeBSD.org
Wed May 21 17:39:50 UTC 2014


Author: marcel
Date: Wed May 21 17:39:49 2014
New Revision: 266514
URL: http://svnweb.freebsd.org/changeset/base/266514

Log:
  Fix CID 1204379 (vtoc8.c) & CID 1204380 (bsd.c): Cast ncyls to lba_t
  before multiplying the 32-bit integrals to avoid any possibility of
  truncation before widening. Not a likely scenario to begin with...

Modified:
  head/usr.bin/mkimg/bsd.c
  head/usr.bin/mkimg/vtoc8.c

Modified: head/usr.bin/mkimg/bsd.c
==============================================================================
--- head/usr.bin/mkimg/bsd.c	Wed May 21 17:38:56 2014	(r266513)
+++ head/usr.bin/mkimg/bsd.c	Wed May 21 17:39:49 2014	(r266514)
@@ -80,7 +80,7 @@ bsd_write(lba_t imgsz, void *bootcode)
 	} else
 		memset(buf, 0, BBSIZE);
 
-	imgsz = ncyls * nheads * nsecs;
+	imgsz = (lba_t)ncyls * nheads * nsecs;
 	error = image_set_size(imgsz);
 	if (error) {
 		free(buf);

Modified: head/usr.bin/mkimg/vtoc8.c
==============================================================================
--- head/usr.bin/mkimg/vtoc8.c	Wed May 21 17:38:56 2014	(r266513)
+++ head/usr.bin/mkimg/vtoc8.c	Wed May 21 17:39:49 2014	(r266514)
@@ -71,7 +71,7 @@ vtoc8_write(lba_t imgsz, void *bootcode 
 	int error, n;
 	uint16_t ofs, sum;
 
-	imgsz = ncyls * nheads * nsecs;
+	imgsz = (lba_t)ncyls * nheads * nsecs;
 
 	memset(&vtoc8, 0, sizeof(vtoc8));
 	sprintf(vtoc8.ascii, "FreeBSD%lldM",


More information about the svn-src-all mailing list