diff options
Diffstat (limited to 'boot.c')
-rw-r--r-- | boot.c | 17 |
1 files changed, 11 insertions, 6 deletions
@@ -193,12 +193,6 @@ readboot(dosfs, boot) /* Check backup FSInfo? XXX */ } - boot->ClusterOffset = (boot->RootDirEnts * 32 + boot->BytesPerSec - 1) - / boot->BytesPerSec - + boot->ResSectors - + boot->FATs * boot->FATsecs - - CLUST_FIRST * boot->SecPerClust; - if (boot->BytesPerSec % DOSBOOTBLOCKSIZE != 0) { pfatal("Invalid sector size: %u", boot->BytesPerSec); return FSFATAL; @@ -207,11 +201,22 @@ readboot(dosfs, boot) pfatal("Invalid cluster size: %u", boot->SecPerClust); return FSFATAL; } + if (boot->BytesPerSec == 0) { + pfatal("Invalid sector size: %u", boot->BytesPerSec); + return FSFATAL; + } if (boot->Sectors) { boot->HugeSectors = 0; boot->NumSectors = boot->Sectors; } else boot->NumSectors = boot->HugeSectors; + + boot->ClusterOffset = (boot->RootDirEnts * 32 + boot->BytesPerSec - 1) + / boot->BytesPerSec + + boot->ResSectors + + boot->FATs * boot->FATsecs + - CLUST_FIRST * boot->SecPerClust; + boot->NumClusters = (boot->NumSectors - boot->ClusterOffset) / boot->SecPerClust; if (boot->flags&FAT32) |