From 95d04099f99cce646c3ea7265e16bfa76724be6b Mon Sep 17 00:00:00 2001 From: otto Date: Fri, 5 Jan 2018 09:33:47 +0000 Subject: [PATCH] the value of bflag is a blockno, so use the proper type, avoids an overflow seen with scanning for alternate superblocks; ok deraadt@ --- sbin/fsck_ffs/fsck.h | 4 ++-- sbin/fsck_ffs/main.c | 13 +++++++------ sbin/fsck_ffs/setup.c | 4 ++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/sbin/fsck_ffs/fsck.h b/sbin/fsck_ffs/fsck.h index 8c90602ca82..99803042c37 100644 --- a/sbin/fsck_ffs/fsck.h +++ b/sbin/fsck_ffs/fsck.h @@ -1,4 +1,4 @@ -/* $OpenBSD: fsck.h,v 1.31 2015/01/19 18:20:47 deraadt Exp $ */ +/* $OpenBSD: fsck.h,v 1.32 2018/01/05 09:33:47 otto Exp $ */ /* $NetBSD: fsck.h,v 1.13 1996/10/11 20:15:46 thorpej Exp $ */ /* @@ -229,7 +229,7 @@ extern long numdirs, listmax, inplast; long secsize; /* actual disk sector size */ char nflag; /* assume a no response */ char yflag; /* assume a yes response */ -int bflag; /* location of alternate super block */ +daddr_t bflag; /* location of alternate super block */ int debug; /* output debugging info */ int cvtlevel; /* convert to newer file system format */ char usedsoftdep; /* just fix soft dependency inconsistencies */ diff --git a/sbin/fsck_ffs/main.c b/sbin/fsck_ffs/main.c index c64dad01686..417ea542c3b 100644 --- a/sbin/fsck_ffs/main.c +++ b/sbin/fsck_ffs/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.50 2016/09/09 15:37:15 tb Exp $ */ +/* $OpenBSD: main.c,v 1.51 2018/01/05 09:33:47 otto Exp $ */ /* $NetBSD: main.c,v 1.22 1996/10/11 20:15:48 thorpej Exp $ */ /* @@ -48,7 +48,7 @@ volatile sig_atomic_t returntosingle; -int argtoi(int, char *, char *, int); +long long argtoi(int, char *, char *, int); int checkfilesys(char *, char *, long, int); int main(int, char *[]); @@ -78,7 +78,8 @@ main(int argc, char *argv[]) case 'b': skipclean = 0; bflag = argtoi('b', "number", optarg, 10); - printf("Alternate super block location: %d\n", bflag); + printf("Alternate super block location: %lld\n", + (long long)bflag); break; case 'c': @@ -140,13 +141,13 @@ main(int argc, char *argv[]) exit(ret); } -int +long long argtoi(int flag, char *req, char *str, int base) { char *cp; - int ret; + long long ret; - ret = (int)strtol(str, &cp, base); + ret = strtoll(str, &cp, base); if (cp == str || *cp) errexit("-%c flag requires a %s\n", flag, req); return (ret); diff --git a/sbin/fsck_ffs/setup.c b/sbin/fsck_ffs/setup.c index 34b4c36cda0..aa77994f094 100644 --- a/sbin/fsck_ffs/setup.c +++ b/sbin/fsck_ffs/setup.c @@ -1,4 +1,4 @@ -/* $OpenBSD: setup.c,v 1.63 2016/09/09 15:37:15 tb Exp $ */ +/* $OpenBSD: setup.c,v 1.64 2018/01/05 09:33:47 otto Exp $ */ /* $NetBSD: setup.c,v 1.27 1996/09/27 22:45:19 christos Exp $ */ /* @@ -202,7 +202,7 @@ setup(char *dev, int isfsdb) } found: doskipclean = 0; - pwarn("USING ALTERNATE SUPERBLOCK AT %d\n", bflag); + pwarn("USING ALTERNATE SUPERBLOCK AT %lld\n", (long long)bflag); } if (debug) printf("clean = %d\n", sblock.fs_clean); -- 2.20.1