Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/makefs/ffs Avoid integer overflow on systems with 3...



details:   https://anonhg.NetBSD.org/src/rev/ca28d5be3f4c
branches:  trunk
changeset: 364647:ca28d5be3f4c
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Sat Apr 02 19:16:49 2022 +0000

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

diffstat:

 usr.sbin/makefs/ffs/mkfs.c |  8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diffs (36 lines):

diff -r 2da888beb44f -r ca28d5be3f4c usr.sbin/makefs/ffs/mkfs.c
--- a/usr.sbin/makefs/ffs/mkfs.c        Sat Apr 02 19:15:09 2022 +0000
+++ b/usr.sbin/makefs/ffs/mkfs.c        Sat Apr 02 19:16:49 2022 +0000
@@ -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 @@
        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 @@
        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);



Home | Main Index | Thread Index | Old Index