]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: vfat: Fix reading labels which starts with byte 0x05
authorPali Rohár <pali.rohar@gmail.com>
Thu, 9 Nov 2017 18:03:34 +0000 (19:03 +0100)
committerKarel Zak <kzak@redhat.com>
Thu, 14 Dec 2017 14:29:59 +0000 (15:29 +0100)
When FAT directory entry has leading byte 0x05 it is interpreted as byte
0xE5. This is how FAT stores file name which starts with byte 0xE5 as
leading byte in 0xE5 in FAT directory entry means that file slot is empty.

Fixes: #533
libblkid/src/superblocks/vfat.c
tests/expected/blkid/low-probe-fat32_cp850_O_tilde [new file with mode: 0644]
tests/ts/blkid/images-fs/fat32_cp850_O_tilde.img.xz [new file with mode: 0644]

index 0cdd2bac7bb43da5ef129615bbe6b658795fc8ac..3aeba018aaa216826a29d55682a581db38f13214 100644 (file)
@@ -165,6 +165,8 @@ static unsigned char *search_fat_label(blkid_probe pr,
                if ((ent->attr & (FAT_ATTR_VOLUME_ID | FAT_ATTR_DIR)) ==
                    FAT_ATTR_VOLUME_ID) {
                        DBG(LOWPROBE, ul_debug("\tfound fs LABEL at entry %d", i));
+                       if (ent->name[0] == 0x05)
+                               ent->name[0] = 0xE5;
                        return ent->name;
                }
        }
diff --git a/tests/expected/blkid/low-probe-fat32_cp850_O_tilde b/tests/expected/blkid/low-probe-fat32_cp850_O_tilde
new file mode 100644 (file)
index 0000000..096bcbf
--- /dev/null
@@ -0,0 +1,7 @@
+ID_FS_LABEL=___
+ID_FS_LABEL_ENC=\xe5\xe5\xe5
+ID_FS_TYPE=vfat
+ID_FS_USAGE=filesystem
+ID_FS_UUID=2826-F9B3
+ID_FS_UUID_ENC=2826-F9B3
+ID_FS_VERSION=FAT32
diff --git a/tests/ts/blkid/images-fs/fat32_cp850_O_tilde.img.xz b/tests/ts/blkid/images-fs/fat32_cp850_O_tilde.img.xz
new file mode 100644 (file)
index 0000000..06eb2c9
Binary files /dev/null and b/tests/ts/blkid/images-fs/fat32_cp850_O_tilde.img.xz differ