From: Karel Zak Date: Thu, 12 Nov 2009 23:10:48 +0000 (+0100) Subject: libblkid: fix NTFS non-ASCII labels X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=832b3f2eb6a6c5f2e7d8db422767404320e45ced;p=util-linux libblkid: fix NTFS non-ASCII labels Addresses-Red-Hat-Bug: #536797 Signed-off-by: Karel Zak --- diff --git a/shlibs/blkid/src/superblocks/ntfs.c b/shlibs/blkid/src/superblocks/ntfs.c index eeba2b69..787deb2c 100644 --- a/shlibs/blkid/src/superblocks/ntfs.c +++ b/shlibs/blkid/src/superblocks/ntfs.c @@ -65,10 +65,9 @@ static int probe_ntfs(blkid_probe pr, const struct blkid_idmag *mag) struct ntfs_super_block *ns; struct master_file_table_record *mft; struct file_attribute *attr; - unsigned char label_str[129], *cp; int bytes_per_sector, sectors_per_cluster; int mft_record_size, attr_off, attr_len; - unsigned int i, attr_type, val_len; + unsigned int attr_type, val_len; int val_off; uint64_t nr_clusters; blkid_loff_t off; @@ -128,7 +127,6 @@ static int probe_ntfs(blkid_probe pr, const struct blkid_idmag *mag) mft = (struct master_file_table_record *) buf_mft; attr_off = le16_to_cpu(mft->attrs_offset); - label_str[0] = 0; while (1) { attr = (struct file_attribute *) (buf_mft + attr_off); @@ -147,16 +145,8 @@ static int probe_ntfs(blkid_probe pr, const struct blkid_idmag *mag) break; if (attr_type == MFT_RECORD_ATTR_VOLUME_NAME) { - if (val_len > sizeof(label_str)) - val_len = sizeof(label_str)-1; - - for (i=0, cp=label_str; i < val_len; i+=2,cp++) { - val = ((uint8_t *) attr) + val_off + i; - *cp = val[0]; - if (val[1]) - *cp = '?'; - } - *cp = 0; + val = ((uint8_t *) attr) + val_off; + blkid_probe_set_utf8label(pr, val, val_len, BLKID_ENC_UTF16LE); } } @@ -164,8 +154,6 @@ static int probe_ntfs(blkid_probe pr, const struct blkid_idmag *mag) (unsigned char *) &ns->volume_serial, sizeof(ns->volume_serial), "%016" PRIX64, le64_to_cpu(ns->volume_serial)); - if (label_str[0]) - blkid_probe_set_label(pr, label_str, strlen((char *)label_str)); return 0; }