From owner-dev-commits-src-all@freebsd.org Tue Feb 2 21:14:03 2021 Return-Path: Delivered-To: dev-commits-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 705EE53DAE8; Tue, 2 Feb 2021 21:14:03 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DVcxl2MPRz4ZLw; Tue, 2 Feb 2021 21:14:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 42292152D9; Tue, 2 Feb 2021 21:14:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 112LE3BZ044875; Tue, 2 Feb 2021 21:14:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 112LE32u044874; Tue, 2 Feb 2021 21:14:03 GMT (envelope-from git) Date: Tue, 2 Feb 2021 21:14:03 GMT Message-Id: <202102022114.112LE32u044874@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: a072e2133ed3 - stable/12 - fstyp(8): fix exfat detection MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: a072e2133ed36f1edf899068e6b026b129c919d8 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Feb 2021 21:14:03 -0000 The branch stable/12 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=a072e2133ed36f1edf899068e6b026b129c919d8 commit a072e2133ed36f1edf899068e6b026b129c919d8 Author: Conrad Meyer AuthorDate: 2021-01-17 19:55:06 +0000 Commit: Ed Maste CommitDate: 2021-02-02 21:12:31 +0000 fstyp(8): fix exfat detection In the presence of high-level errors (spec violations, bad boot blocks checksum), report non-detection instead of detection. PR: 252787 (related, but does not fully address) (cherry picked from commit ddf61156132b610915325769cbb93ea11be0d433) --- usr.sbin/fstyp/exfat.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/usr.sbin/fstyp/exfat.c b/usr.sbin/fstyp/exfat.c index d77ba9253d39..3f10cb6a9e5a 100644 --- a/usr.sbin/fstyp/exfat.c +++ b/usr.sbin/fstyp/exfat.c @@ -330,14 +330,15 @@ fstyp_exfat(FILE *fp, char *label, size_t size) uint32_t chksum; int error; + error = 1; cksect = NULL; ev = (struct exfat_vbr *)read_buf(fp, 0, 512); if (ev == NULL || strncmp(ev->ev_fsname, "EXFAT ", 8) != 0) - goto fail; + goto out; if (ev->ev_log_bytes_per_sect < 9 || ev->ev_log_bytes_per_sect > 12) { warnx("exfat: Invalid BytesPerSectorShift"); - goto done; + goto out; } bytespersec = (1u << ev->ev_log_bytes_per_sect); @@ -345,7 +346,7 @@ fstyp_exfat(FILE *fp, char *label, size_t size) error = exfat_compute_boot_chksum(fp, MAIN_BOOT_REGION_SECT, bytespersec, &chksum); if (error != 0) - goto done; + goto out; cksect = read_sect(fp, MAIN_BOOT_REGION_SECT + SUBREGION_CHKSUM_SECT, bytespersec); @@ -357,7 +358,8 @@ fstyp_exfat(FILE *fp, char *label, size_t size) if (chksum != le32toh(cksect[0])) { warnx("exfat: Found checksum 0x%08x != computed 0x%08x", le32toh(cksect[0]), chksum); - goto done; + error = 1; + goto out; } #ifdef WITH_ICONV @@ -365,12 +367,8 @@ fstyp_exfat(FILE *fp, char *label, size_t size) exfat_find_label(fp, ev, bytespersec, label, size); #endif -done: +out: free(cksect); free(ev); - return (0); - -fail: - free(ev); - return (1); + return (error != 0); }