diff options
author | Steve Kondik <shade@chemlab.org> | 2012-11-18 15:18:02 -0800 |
---|---|---|
committer | Steve Kondik <shade@chemlab.org> | 2012-11-18 15:18:02 -0800 |
commit | 6ff3a58bcd3223f15def43ddd39d3921d855494b (patch) | |
tree | a7ba2a506d59419940f1ef418e2d05da8fc4139f | |
parent | f9b92a9ae61fc0e147a068d4bd5396ce521176d1 (diff) | |
parent | ed86a9f77e796aa5923a5b2d1455a7739b86e60b (diff) | |
download | android_external_fsck_msdos-6ff3a58bcd3223f15def43ddd39d3921d855494b.tar.gz android_external_fsck_msdos-6ff3a58bcd3223f15def43ddd39d3921d855494b.tar.bz2 android_external_fsck_msdos-6ff3a58bcd3223f15def43ddd39d3921d855494b.zip |
Merge branch 'jb-mr1-release' of https://android.googlesource.com/platform/external/fsck_msdos into mr1-stagingcm-10.1.3-RC2cm-10.1.3-RC1cm-10.1.3cm-10.1.2cm-10.1.1cm-10.1.0-RC5cm-10.1.0-RC4cm-10.1.0-RC3cm-10.1.0-RC2cm-10.1.0-RC1cm-10.1.0cm-10.1-M3cm-10.1-M2cm-10.1-M1mr1.1-stagingcm-10.1
-rw-r--r-- | boot.c | 21 |
1 files changed, 15 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,26 @@ 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->FATs == 0) { + pfatal("Invalid number of FATs: %u", boot->FATs); + 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) |