Menu

#52 Looking beyond end of directory cluster in FAT32

open
nobody
None
5
2012-11-28
2011-10-11
Anonymous
No

In probe_fat() it appears that the code doesn't stop looping through clusters when the "last cluster in file" is encountered. (Presumably) usually it exits when maxloop is decremented to zero, falling back to using the label in the boot sector, but sometimes a file data sector happens to appear to have a valid volume label file, causing the volume label to be determined incorrectly.

The included patch exits the loop when the "last cluster in file" FAT entry value is encountered.

--- a/lib/blkid/probe.c
+++ b/lib/blkid/probe.c
@@ -582,7 +582,7 @@ static int probe_fat(struct blkid_probe *probe,
start_data_sect = reserved + fat_size;

next = blkid_le32(vs->vs_root_cluster);
- while (next && --maxloop) {
+ while (next && --maxloop && (next != 0x0fffffff)) {
__u32 next_sect_off;
__u64 next_off, fat_entry_off;
int count;

Discussion