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)
This commit is contained in:
parent
f3ea417f96
commit
ddf6115613
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user