Skip to content

Conversation

@sftse
Copy link
Contributor

@sftse sftse commented Oct 23, 2025

This fix was prompted by errors of the form Malformed FAT (FAT has 1770 entries, but file has only 1675 sectors).

Similar to #65 this is because mislabeled FAT sectors beyond the end of the file:

    header: Header {
        version: V3,
        num_dir_sectors: 0,
        num_fat_sectors: 14,
        first_dir_sector: 1631,
        first_minifat_sector: 0,
        num_minifat_sectors: 3,
        first_difat_sector: EOC,
        num_difat_sectors: 0,
        initial_difat_entries: [
            1661..=1674,
        ],
    },
    difat: [
        1661..=1674,
        95 FREE,
    ],
    fat: [
        1..=2,
        EOC,
        4..=1630,
        EOC,
        1632..=1660,
        EOC,
        109 FAT,
        22 FREE,
    ],

It also might make sense at this point to just truncate the FAT if it is longer than the number of sectors, instead of stripping off special cases from the end. Is there really anything else one could try if they dont match?

@mdsteele mdsteele merged commit aa086a8 into mdsteele:master Oct 25, 2025
4 checks passed
@mdsteele
Copy link
Owner

Thanks!

@sftse sftse deleted the c-dev branch October 27, 2025 08:46
@sftse
Copy link
Contributor Author

sftse commented Oct 29, 2025

Thanks for the quick turn-around! Can we have a release?

@mdsteele
Copy link
Owner

mdsteele commented Nov 8, 2025

Published as v0.12.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants