Module Name: src
Committed By: tkusumi
Date: Sun Jan 24 14:37:32 UTC 2021
Modified Files:
src/usr.sbin/fstyp: exfat.c
Log Message:
fstyp: Fix exfat detection
taken-from FreeBSD ddf61156132b610915325769cbb93ea11be0d433
To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/fstyp/exfat.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.sbin/fstyp/exfat.c
diff -u src/usr.sbin/fstyp/exfat.c:1.3 src/usr.sbin/fstyp/exfat.c:1.4
--- src/usr.sbin/fstyp/exfat.c:1.3 Sat Feb 8 12:56:56 2020
+++ src/usr.sbin/fstyp/exfat.c Sun Jan 24 14:37:32 2021
@@ -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 <[email protected]>
@@ -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 @@ fstyp_exfat(FILE *fp, char *label, 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);
@@ -343,7 +343,7 @@ fstyp_exfat(FILE *fp, char *label, 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);
@@ -355,18 +355,15 @@ fstyp_exfat(FILE *fp, char *label, 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;
}
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);
}