From: Pali Rohár Date: Tue, 16 May 2017 21:52:05 +0000 (+0200) Subject: libblkid: udf: Correctly handle UDF strings encoded in 8bit OSTA Compressed Unicode X-Git-Tag: v2.30-rc2~33 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=22acc2681de1ae2e10d7f1e7e62538af37bc2982;p=thirdparty%2Futil-linux.git libblkid: udf: Correctly handle UDF strings encoded in 8bit OSTA Compressed Unicode String encoded in 8bit OSTA Compressed Unicode contains one Unicode codepoint per 8bits. Maximal Unicode codepoint is U+FF. Which effectively means that it is equivalent to Latin1 encoding. Before this patch libblkid copied raw 8bit OSTA Compressed Unicode from disk and treated it as UTF-8. It worked fine just for UTF-8 invariants, other characters were incorrectly encoded. This patch fixes this problem. Note that processing UUID is not fixed in this patch. --- diff --git a/libblkid/src/superblocks/udf.c b/libblkid/src/superblocks/udf.c index 36769779f5..96254d8813 100644 --- a/libblkid/src/superblocks/udf.c +++ b/libblkid/src/superblocks/udf.c @@ -218,8 +218,9 @@ real_blksz: if (!have_volid) { uint8_t clen = vd->type.primary.ident.clen; if (clen == 8) - have_volid = !blkid_probe_set_id_label(pr, "VOLUME_ID", - vd->type.primary.ident.c, 31); + have_volid = !blkid_probe_set_utf8_id_label(pr, "VOLUME_ID", + vd->type.primary.ident.c, 31, + BLKID_ENC_LATIN1); else if (clen == 16) have_volid = !blkid_probe_set_utf8_id_label(pr, "VOLUME_ID", vd->type.primary.ident.c, 31, @@ -261,8 +262,9 @@ real_blksz: if (!have_volsetid) { uint8_t clen = vd->type.primary.volset_id.clen; if (clen == 8) - have_volsetid = !blkid_probe_set_id_label(pr, "VOLUME_SET_ID", - vd->type.primary.volset_id.c, 127); + have_volsetid = !blkid_probe_set_utf8_id_label(pr, "VOLUME_SET_ID", + vd->type.primary.volset_id.c, 127, + BLKID_ENC_LATIN1); else if (clen == 16) have_volsetid = !blkid_probe_set_utf8_id_label(pr, "VOLUME_SET_ID", vd->type.primary.volset_id.c, 127, @@ -299,11 +301,13 @@ real_blksz: uint8_t clen = vd->type.logical.logvol_id.clen; if (clen == 8) { if (!have_label) - have_label = !blkid_probe_set_label(pr, - vd->type.logical.logvol_id.c, 127); + have_label = !blkid_probe_set_utf8label(pr, + vd->type.logical.logvol_id.c, 127, + BLKID_ENC_LATIN1); if (!have_logvolid) - have_logvolid = !blkid_probe_set_id_label(pr, "LOGICAL_VOLUME_ID", - vd->type.logical.logvol_id.c, 127); + have_logvolid = !blkid_probe_set_utf8_id_label(pr, "LOGICAL_VOLUME_ID", + vd->type.logical.logvol_id.c, 127, + BLKID_ENC_LATIN1); } else if (clen == 16) { if (!have_label) have_label = !blkid_probe_set_utf8label(pr,