mirror of
https://github.com/limine-bootloader/limine
synced 2024-11-23 09:02:11 +03:00
mbr: Add extra FAT32 and NTFS signatures to validity check
This commit is contained in:
parent
abf86a561a
commit
1ac1343059
@ -276,12 +276,18 @@ static bool is_valid_mbr(struct volume *volume) {
|
||||
volume_read(volume, hintc, 4, 8);
|
||||
if (memcmp(hintc, "_ECH_FS_", 8) == 0)
|
||||
return false;
|
||||
volume_read(volume, hintc, 3, 4);
|
||||
if (memcmp(hintc, "NTFS", 4) == 0)
|
||||
return false;
|
||||
volume_read(volume, hintc, 54, 3);
|
||||
if (memcmp(hintc, "FAT", 3) == 0)
|
||||
return false;
|
||||
volume_read(volume, hintc, 82, 3);
|
||||
if (memcmp(hintc, "FAT", 3) == 0)
|
||||
return false;
|
||||
volume_read(volume, hintc, 3, 5);
|
||||
if (memcmp(hintc, "FAT32", 5) == 0)
|
||||
return false;
|
||||
volume_read(volume, &hint, 1080, sizeof(uint16_t));
|
||||
if (hint == 0xef53)
|
||||
return false;
|
||||
|
@ -496,6 +496,15 @@ int main(int argc, char *argv[]) {
|
||||
device_write(hintc, 4, 8);
|
||||
}
|
||||
}
|
||||
device_read(hintc, 3, 4);
|
||||
if (memcmp(hintc, "NTFS", 4) == 0) {
|
||||
if (!force_mbr) {
|
||||
mbr = 0;
|
||||
} else {
|
||||
memset(hintc, 0, 4);
|
||||
device_write(hintc, 3, 4);
|
||||
}
|
||||
}
|
||||
device_read(hintc, 54, 3);
|
||||
if (memcmp(hintc, "FAT", 3) == 0) {
|
||||
if (!force_mbr) {
|
||||
@ -514,6 +523,15 @@ int main(int argc, char *argv[]) {
|
||||
device_write(hintc, 82, 5);
|
||||
}
|
||||
}
|
||||
device_read(hintc, 3, 5);
|
||||
if (memcmp(hintc, "FAT32", 5) == 0) {
|
||||
if (!force_mbr) {
|
||||
mbr = 0;
|
||||
} else {
|
||||
memset(hintc, 0, 5);
|
||||
device_write(hintc, 3, 5);
|
||||
}
|
||||
}
|
||||
device_read(&hint16, 1080, sizeof(uint16_t));
|
||||
hint16 = ENDSWAP(hint16);
|
||||
if (hint16 == 0xef53) {
|
||||
@ -537,8 +555,8 @@ int main(int argc, char *argv[]) {
|
||||
if (gpt == 0 && mbr == 0) {
|
||||
fprintf(stderr, "ERROR: Could not determine if the device has a valid partition table.\n");
|
||||
fprintf(stderr, " Please ensure the device has a valid MBR or GPT.\n");
|
||||
fprintf(stderr, " Alternatively, pass `--force-mbr` to override these checks. ONLY\n");
|
||||
fprintf(stderr, " DO THIS AT YOUR OWN RISK, DATA LOSS MAY OCCUR!\n");
|
||||
fprintf(stderr, " Alternatively, pass `--force-mbr` to override these checks.\n");
|
||||
fprintf(stderr, " **ONLY DO THIS AT YOUR OWN RISK, DATA LOSS MAY OCCUR!**\n");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user