:: commit afedae6d081ba53c9857cdbbfc0e1d1a51e44da3

mintsuki <mintsuki@protonmail.com> — 2022-07-09 10:25

parents: 71adb6b307

fat32: Swallow 0x28 and 0xd0 extended boot signatures

diff --git a/common/fs/fat32.s2.c b/common/fs/fat32.s2.c
index 2c650f9a..0eac8296 100644
--- a/common/fs/fat32.s2.c
+++ b/common/fs/fat32.s2.c
@@ -112,11 +112,7 @@ static int fat32_init_context(struct fat32_context* context, struct volume *part
     // Checks for FAT12/16
     if (strncmp((((void *)&bpb) + 0x36), "FAT", 3) == 0) {
         if (*(((uint8_t *)&bpb) + 0x26) != 0x29) {
-            for (size_t i = 0; i < 15; i++) {
-                if (*(((uint8_t *)&bpb) + 0x27 + i) != 0) {
-                    return 1;
-                }
-            }
+            return 1;
         }
 
         goto valid;
@@ -124,12 +120,10 @@ static int fat32_init_context(struct fat32_context* context, struct volume *part
 
     // Checks for FAT32
     if (strncmp((((void *)&bpb) + 0x52), "FAT", 3) == 0) {
-        if (*(((uint8_t *)&bpb) + 0x42) != 0x29) {
-            for (size_t i = 0; i < 15; i++) {
-                if (*(((uint8_t *)&bpb) + 0x43 + i) != 0) {
-                    return 1;
-                }
-            }
+        uint8_t sig = *(((uint8_t *)&bpb) + 0x42);
+
+        if (sig != 0x29 && sig != 0x28 && sig != 0xd0) {
+            return 1;
         }
 
         goto valid;
tab: 248 wrap: offon