diff options
Diffstat (limited to 'fat.c')
-rw-r--r-- | fat.c | 22 |
1 files changed, 12 insertions, 10 deletions
@@ -692,16 +692,18 @@ checklost(int dosfs, struct bootblock *boot, struct fatEntry *fat) ret = 1; } } - if (boot->NumFree && fat[boot->FSNext].next != CLUST_FREE) { - pwarn("Next free cluster in FSInfo block (%u) not free\n", - boot->FSNext); - if (ask(1, "Fix")) - for (head = CLUST_FIRST; head < boot->NumClusters; head++) - if (fat[head].next == CLUST_FREE) { - boot->FSNext = head; - ret = 1; - break; - } + if (boot->NumFree) { + if ((boot->FSNext >= boot->NumClusters) || (fat[boot->FSNext].next != CLUST_FREE)) { + pwarn("Next free cluster in FSInfo block (%u) not free\n", + boot->FSNext); + if (ask(1, "Fix")) + for (head = CLUST_FIRST; head < boot->NumClusters; head++) + if (fat[head].next == CLUST_FREE) { + boot->FSNext = head; + ret = 1; + break; + } + } } if (ret) mod |= writefsinfo(dosfs, boot); |