Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/fstyp fstyp: Fix exfat detection



details:   https://anonhg.NetBSD.org/src/rev/b0d3a31f7b96
branches:  trunk
changeset: 950299:b0d3a31f7b96
user:      tkusumi <tkusumi%NetBSD.org@localhost>
date:      Sun Jan 24 14:37:32 2021 +0000

description:
fstyp: Fix exfat detection

taken-from FreeBSD ddf61156132b610915325769cbb93ea11be0d433

diffstat:

 usr.sbin/fstyp/exfat.c |  23 ++++++++++-------------
 1 files changed, 10 insertions(+), 13 deletions(-)

diffs (69 lines):

diff -r 9736d5b357c7 -r b0d3a31f7b96 usr.sbin/fstyp/exfat.c
--- a/usr.sbin/fstyp/exfat.c    Sun Jan 24 14:33:49 2021 +0000
+++ b/usr.sbin/fstyp/exfat.c    Sun Jan 24 14:37:32 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: exfat.c,v 1.3 2020/02/08 12:56:56 fox Exp $    */
+/*     $NetBSD: exfat.c,v 1.4 2021/01/24 14:37:32 tkusumi Exp $        */
 
 /*
  * Copyright (c) 2017 Conrad Meyer <cem%FreeBSD.org@localhost>
@@ -26,7 +26,7 @@
  * SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: exfat.c,v 1.3 2020/02/08 12:56:56 fox Exp $");
+__RCSID("$NetBSD: exfat.c,v 1.4 2021/01/24 14:37:32 tkusumi Exp $");
 
 #include <sys/param.h>
 #include <sys/endian.h>
@@ -327,15 +327,15 @@
        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);
@@ -343,7 +343,7 @@
        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);
@@ -355,18 +355,15 @@
        if (chksum != le32toh(cksect[0])) {
                warnx("exfat: Found checksum 0x%08x != computed 0x%08x",
                    le32toh(cksect[0]), chksum);
-               goto done;
+               error = 1;
+               goto out;
        }
 
        if (show_label)
                exfat_find_label(fp, ev, bytespersec, label, size);
 
-done:
+out:
        free(cksect);
        free(ev);
-       return (0);
-
-fail:
-       free(ev);
-       return (1);
+       return (error != 0);
 }



Home | Main Index | Thread Index | Old Index