From e526f503918cc29d8b1ccf36a5c3a34645d2be6e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Pali=20Roh=C3=A1r?= Date: Thu, 9 Nov 2017 19:03:34 +0100 Subject: [PATCH] libblkid: vfat: Fix reading labels which starts with byte 0x05 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 | 2 ++ .../expected/blkid/low-probe-fat32_cp850_O_tilde | 7 +++++++ .../blkid/images-fs/fat32_cp850_O_tilde.img.xz | Bin 0 -> 5400 bytes 3 files changed, 9 insertions(+) create mode 100644 tests/expected/blkid/low-probe-fat32_cp850_O_tilde create mode 100644 tests/ts/blkid/images-fs/fat32_cp850_O_tilde.img.xz diff --git a/libblkid/src/superblocks/vfat.c b/libblkid/src/superblocks/vfat.c index 0cdd2bac7b..3aeba018aa 100644 --- a/libblkid/src/superblocks/vfat.c +++ b/libblkid/src/superblocks/vfat.c @@ -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 index 0000000000..096bcbf2c1 --- /dev/null +++ b/tests/expected/blkid/low-probe-fat32_cp850_O_tilde @@ -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 index 0000000000000000000000000000000000000000..06eb2c978e54f3314f18218eade2a0f16a7b6ab9 GIT binary patch literal 5400 zc-s4GUKJ6=z`*kC+7>q^21Q001_lO!^ATtM|KG?I8Ou;QjgReeNoCNjgpc0e7xV}3 z_j0dZG_PXkBY~w)?<$8Z(3BIpRrtx`bR*wFo=2*yb`};H3%s}xbbGNz;6?9U_Y=gE zr*w<8`FcJsjm&6^|Jb!M{@jhGLlN%HKFr07j{g)%IPBjYW-4*QwZ6mlvO9zF#@Rc6 zrA{wti0X^j!d&yaWv-R0BWK>^o&}H9HJ+S{09&wKf6fytbEVK@t02qFF6FWzF09{{Wr>Bt%;x1OTSAVV4LAPXk z(Eu9_u+ab;4Y1Jw8x64002>Xk(Eu9_u+ab;Tmd$L&yQi&pbW5A3Q-I{7#NmbyYpm% f^=e%P#xI%;4F?3wRxFF&cqIKd69W*iL`DGs9<`F- literal 0 Hc-jL100001 -- 2.47.3