diff options
author | Jean-Baptiste Queru <jbq@google.com> | 2013-07-08 22:33:32 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2013-07-08 22:33:33 +0000 |
commit | b94f2b6107f2adfd635fbec55ce6105687eb68b3 (patch) | |
tree | d09c9552b273c6f4afbed7db6ba674539bcfde66 | |
parent | ed86a9f77e796aa5923a5b2d1455a7739b86e60b (diff) | |
parent | f03428811bed72a009839b1616ffcac11fcfd6b0 (diff) | |
download | fsck_msdos-b94f2b6107f2adfd635fbec55ce6105687eb68b3.tar.gz |
Merge "Detect exFAT filesystems and abort if found"tools_r22.2jb-mr1.1-dev-plus-aosp
-rw-r--r-- | boot.c | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -106,6 +106,25 @@ readboot(dosfs, boot) boot->FSInfo = block[48] + (block[49] << 8); boot->Backup = block[50] + (block[51] << 8); + /* If the OEM Name field is EXFAT, it's not FAT32, so bail */ + if (!memcmp(&block[3], "EXFAT ", 8)) { + pfatal("exFAT filesystem is not supported."); + return FSFATAL; + } + + /* check basic parameters */ + if ((boot->FSInfo == 0) || + (boot->BytesPerSec % DOSBOOTBLOCKSIZE != 0) || + (boot->BytesPerSec / DOSBOOTBLOCKSIZE == 0) || + (boot->SecPerClust == 0)) { + /* + * Either the BIOS Parameter Block has been corrupted, + * or this is not a FAT32 filesystem, most likely an + * exFAT filesystem. + */ + pfatal("Invalid FAT32 Extended BIOS Parameter Block"); + return FSFATAL; + } if (lseek(dosfs, boot->FSInfo * boot->BytesPerSec, SEEK_SET) != boot->FSInfo * boot->BytesPerSec || read(dosfs, fsinfo, sizeof fsinfo) |