[parted] - Fix a problem with GPT Partition names using. They are UCS-2LE not UTF-16

Brian C. Lane bcl at fedoraproject.org
Fri May 16 20:17:04 UTC 2014


commit f0247c09aaef15ca799186f9d9e71b29b8fa8193
Author: Brian C. Lane <bcl at redhat.com>
Date:   Fri May 16 13:15:33 2014 -0700

    - Fix a problem with GPT Partition names using. They are UCS-2LE not UTF-16

 0100-GPT-strings-are-UCS-2LE-not-UTF-16.patch |   55 +++++++++++++++++++++++++
 parted.spec                                   |    7 ++-
 2 files changed, 60 insertions(+), 2 deletions(-)
---
diff --git a/0100-GPT-strings-are-UCS-2LE-not-UTF-16.patch b/0100-GPT-strings-are-UCS-2LE-not-UTF-16.patch
new file mode 100644
index 0000000..66c353f
--- /dev/null
+++ b/0100-GPT-strings-are-UCS-2LE-not-UTF-16.patch
@@ -0,0 +1,55 @@
+From 77ce72ddf2bfbb34c8ef02ab955acbec20d643db Mon Sep 17 00:00:00 2001
+From: "Brian C. Lane" <bcl at redhat.com>
+Date: Fri, 16 May 2014 10:23:28 -0700
+Subject: [PATCH] GPT strings are UCS-2LE not UTF-16
+
+There was a problem using UTF-16, it was writing the Byte Order Mark
+before the string which caused problems with older versions of parted
+reading the partition name. The test was skipping these 2 bytes when
+checking the written string.
+
+* libparted/labels/gpt.c: Switch to UCS-2LE for GPT Partition names
+* tests/t0251-gpt-unicode.sh: Update the test
+---
+ libparted/labels/gpt.c     | 4 ++--
+ tests/t0251-gpt-unicode.sh | 2 +-
+ 2 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
+index 31f6d17..c19cb59 100644
+--- a/libparted/labels/gpt.c
++++ b/libparted/labels/gpt.c
+@@ -1891,7 +1891,7 @@ gpt_partition_set_name (PedPartition *part, const char *name)
+ 
+   free(gpt_part_data->translated_name);
+   gpt_part_data->translated_name = xstrdup(name);
+-  iconv_t conv = iconv_open ("UTF-16", nl_langinfo (CODESET));
++  iconv_t conv = iconv_open ("UCS-2LE", nl_langinfo (CODESET));
+   if (conv == (iconv_t)-1)
+     goto err;
+   char *inbuff = gpt_part_data->translated_name;
+@@ -1916,7 +1916,7 @@ gpt_partition_get_name (const PedPartition *part)
+   if (gpt_part_data->translated_name == NULL)
+     {
+       char buffer[200];
+-      iconv_t conv = iconv_open (nl_langinfo (CODESET), "UTF-16");
++      iconv_t conv = iconv_open (nl_langinfo (CODESET), "UCS-2LE");
+       if (conv == (iconv_t)-1)
+ 	goto err;
+       char *inbuff = (char *)&gpt_part_data->name;
+diff --git a/tests/t0251-gpt-unicode.sh b/tests/t0251-gpt-unicode.sh
+index 36a4c26..fbffbcb 100755
+--- a/tests/t0251-gpt-unicode.sh
++++ b/tests/t0251-gpt-unicode.sh
+@@ -31,7 +31,7 @@ parted -s $dev mklabel gpt mkpart primary ext2 1MiB 2MiB name 1 $part_name > emp
+ compare /dev/null empty || fail=1
+ 
+ # check for expected output
+-dd if=$dev bs=1 skip=$(($sector_size_+$sector_size_+58)) count=10 2>/dev/null | od -An -tx1 > out || fail=1
++dd if=$dev bs=1 skip=$(($sector_size_+$sector_size_+56)) count=10 2>/dev/null | od -An -tx1 > out || fail=1
+ echo ' 66 00 6f 00 6f 00 24 1d 00 00' >> exp
+ compare exp out || fail=1
+ 
+-- 
+1.9.0
+
diff --git a/parted.spec b/parted.spec
index 5dfdf2c..ae5322b 100644
--- a/parted.spec
+++ b/parted.spec
@@ -4,7 +4,7 @@
 Summary: The GNU disk partition manipulation program
 Name:    parted
 Version: 3.1
-Release: 21%{?dist}
+Release: 22%{?dist}
 License: GPLv3+
 Group:   Applications/System
 URL:     http://www.gnu.org/software/parted
@@ -122,7 +122,7 @@ Patch0096: 0096-tests-Make-t4100-xfs-filesystem-larger-and-sparse.patch
 Patch0097: 0097-libparted-Fix-part-dupe-with-empty-name.patch
 Patch0098: 0098-tests-check-name-when-duplicating.patch
 Patch0099: 0099-tests-Add-ntfs-vfat-hfsplus-to-t1700-probe-test.patch
-
+Patch0100: 0100-GPT-strings-are-UCS-2LE-not-UTF-16.patch
 
 Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 BuildRequires: e2fsprogs-devel
@@ -261,6 +261,9 @@ fi
 
 
 %changelog
+* Fri May 16 2014 Brian C. Lane <bcl at redhat.com> 3.1-22
+- Fix a problem with GPT Partition names using. They are UCS-2LE not UTF-16
+
 * Fri Apr 18 2014 Brian C. Lane <bcl at redhat.com> 3.1-21
 - Fix t1700 probe patch -- remove loop before making new fs
 


More information about the scm-commits mailing list