Module Name:    src
Committed By:   mlelstv
Date:           Sat Apr  2 19:16:49 UTC 2022

Modified Files:
        src/usr.sbin/makefs/ffs: mkfs.c

Log Message:
Avoid integer overflow on systems with 32bit disk addresses.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/usr.sbin/makefs/ffs/mkfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/ffs/mkfs.c
diff -u src/usr.sbin/makefs/ffs/mkfs.c:1.39 src/usr.sbin/makefs/ffs/mkfs.c:1.40
--- src/usr.sbin/makefs/ffs/mkfs.c:1.39	Thu Mar 26 04:25:28 2020
+++ src/usr.sbin/makefs/ffs/mkfs.c	Sat Apr  2 19:16:49 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: mkfs.c,v 1.39 2020/03/26 04:25:28 kre Exp $	*/
+/*	$NetBSD: mkfs.c,v 1.40 2022/04/02 19:16:49 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 2002 Networks Associates Technology, Inc.
@@ -48,7 +48,7 @@
 static char sccsid[] = "@(#)mkfs.c	8.11 (Berkeley) 5/3/95";
 #else
 #ifdef __RCSID
-__RCSID("$NetBSD: mkfs.c,v 1.39 2020/03/26 04:25:28 kre Exp $");
+__RCSID("$NetBSD: mkfs.c,v 1.40 2022/04/02 19:16:49 mlelstv Exp $");
 #endif
 #endif
 #endif /* not lint */
@@ -796,7 +796,7 @@ ffs_rdfs(daddr_t bno, int size, void *bf
 	int n;
 	off_t offset;
 
-	offset = bno * fsopts->sectorsize + fsopts->offset;
+	offset = bno * (off_t)fsopts->sectorsize + fsopts->offset;
 	if (lseek(fsopts->fd, offset, SEEK_SET) < 0)
 		err(EXIT_FAILURE, "%s: seek error for sector %lld", __func__,
 		    (long long)bno);
@@ -819,7 +819,7 @@ ffs_wtfs(daddr_t bno, int size, void *bf
 	int n;
 	off_t offset;
 
-	offset = bno * fsopts->sectorsize + fsopts->offset;
+	offset = bno * (off_t)fsopts->sectorsize + fsopts->offset;
 	if (lseek(fsopts->fd, offset, SEEK_SET) == -1)
 		err(EXIT_FAILURE, "%s: seek error @%jd for sector %jd",
 		    __func__, (intmax_t)offset, (intmax_t)bno);

Reply via email to