]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: udf: Correctly handle UDF strings encoded in 8bit OSTA Compressed Unicode
authorPali Rohár <pali.rohar@gmail.com>
Tue, 16 May 2017 21:52:05 +0000 (23:52 +0200)
committerPali Rohár <pali.rohar@gmail.com>
Tue, 16 May 2017 21:52:05 +0000 (23:52 +0200)
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.

libblkid/src/superblocks/udf.c

index 36769779f520b2eb004a3027cf98162f6bf7a959..96254d8813a9a72f5f76082eb61c27ea08ff1097 100644 (file)
@@ -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,