From owner-svn-src-all@freebsd.org Fri May 1 04:16:57 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BD2E22D1C8D; Fri, 1 May 2020 04:16:57 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49CzV14b7Hz4Sx7; Fri, 1 May 2020 04:16:57 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7ED2A2305; Fri, 1 May 2020 04:16:57 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0414GvR6052770; Fri, 1 May 2020 04:16:57 GMT (envelope-from delphij@FreeBSD.org) Received: (from delphij@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0414Gv8v052769; Fri, 1 May 2020 04:16:57 GMT (envelope-from delphij@FreeBSD.org) Message-Id: <202005010416.0414Gv8v052769@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: delphij set sender to delphij@FreeBSD.org using -f From: Xin LI Date: Fri, 1 May 2020 04:16:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r360520 - stable/12/sbin/fsck_msdosfs X-SVN-Group: stable-12 X-SVN-Commit-Author: delphij X-SVN-Commit-Paths: stable/12/sbin/fsck_msdosfs X-SVN-Commit-Revision: 360520 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 May 2020 04:16:57 -0000 Author: delphij Date: Fri May 1 04:16:57 2020 New Revision: 360520 URL: https://svnweb.freebsd.org/changeset/base/360520 Log: MFC r360428: Do not overflow when calculating file system size. Modified: stable/12/sbin/fsck_msdosfs/check.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sbin/fsck_msdosfs/check.c ============================================================================== --- stable/12/sbin/fsck_msdosfs/check.c Fri May 1 01:31:19 2020 (r360519) +++ stable/12/sbin/fsck_msdosfs/check.c Fri May 1 04:16:57 2020 (r360520) @@ -54,6 +54,8 @@ checkfilesys(const char *fname) int finish_dosdirsection=0; int mod = 0; int ret = 8; + int64_t freebytes; + int64_t badbytes; rdonly = alwaysno; if (!preen) @@ -129,37 +131,33 @@ checkfilesys(const char *fname) mod |= FSERROR; } + freebytes = (int64_t)boot.NumFree * boot.ClusterSize; + badbytes = (int64_t)boot.NumBad * boot.ClusterSize; + #ifdef HAVE_LIBUTIL_H char freestr[7], badstr[7]; - int64_t freebytes = boot.NumFree * boot.ClusterSize; humanize_number(freestr, sizeof(freestr), freebytes, "", HN_AUTOSCALE, HN_DECIMAL | HN_IEC_PREFIXES); if (boot.NumBad) { - int64_t badbytes = boot.NumBad * boot.ClusterSize; - humanize_number(badstr, sizeof(badstr), badbytes, "", HN_AUTOSCALE, HN_B | HN_DECIMAL | HN_IEC_PREFIXES); pwarn("%d files, %sB free (%d clusters), %sB bad (%d clusters)\n", - boot.NumFiles, - freestr, boot.NumFree, + boot.NumFiles, freestr, boot.NumFree, badstr, boot.NumBad); } else { pwarn("%d files, %sB free (%d clusters)\n", - boot.NumFiles, - freestr, boot.NumFree); + boot.NumFiles, freestr, boot.NumFree); } #else if (boot.NumBad) - pwarn("%d files, %d KiB free (%d clusters), %d KiB bad (%d clusters)\n", - boot.NumFiles, - boot.NumFree * boot.ClusterSize / 1024, boot.NumFree, - boot.NumBad * boot.ClusterSize / 1024, boot.NumBad); + pwarn("%d files, %jd KiB free (%d clusters), %jd KiB bad (%d clusters)\n", + boot.NumFiles, (intmax_t)freebytes / 1024, boot.NumFree, + (intmax_t)badbytes / 1024, boot.NumBad); else - pwarn("%d files, %d KiB free (%d clusters)\n", - boot.NumFiles, - boot.NumFree * boot.ClusterSize / 1024, boot.NumFree); + pwarn("%d files, %jd KiB free (%d clusters)\n", + boot.NumFiles, (intmax_t)freebytes / 1024, boot.NumFree); #endif if (mod && (mod & FSERROR) == 0) {