diff --git a/libgpod-handle-partial-utf16.patch b/libgpod-handle-partial-utf16.patch new file mode 100644 index 0000000..fd883cd --- /dev/null +++ b/libgpod-handle-partial-utf16.patch @@ -0,0 +1,44 @@ +--- libgpod-0.7.2/src/itdb_itunesdb.c 2009-12-10 14:39:04.000000000 +0000 ++++ libgpod-0.7.2.new/src/itdb_itunesdb.c 2009-12-10 14:56:22.000000000 +0000 +@@ -811,6 +811,22 @@ static inline guint64 get64bint (FConten + } + + ++/* Try to convert from UTF-16 to UTF-8 and handle partial characters ++ * at the end of the string */ ++static char *utf16_to_utf8_with_partial (gunichar2 *entry_utf16) ++{ ++ GError *error = NULL; ++ char *entry_utf8; ++ glong items_read; ++ ++ entry_utf8 = g_utf16_to_utf8 (entry_utf16, -1, &items_read, NULL, &error); ++ if (entry_utf8 == NULL && g_error_matches (error, G_CONVERT_ERROR, G_CONVERT_ERROR_PARTIAL_INPUT)) { ++ g_error_free (error); ++ entry_utf8 = g_utf16_to_utf8 (entry_utf16, items_read, NULL, NULL, NULL); ++ } ++ ++ return entry_utf8; ++} + + + /* Fix little endian UTF16 String to correct byteorder if necessary +@@ -1302,7 +1318,7 @@ static char *extract_mhod_string (FConte + entry_utf16 = g_new0 (gunichar2, (len+2)/2); + if (seek_get_n_bytes (cts, (gchar *)entry_utf16, seek+16, len)) { + fixup_little_utf16 (entry_utf16); +- entry_utf8= g_utf16_to_utf8 (entry_utf16, -1, NULL, NULL, NULL); ++ entry_utf8 = utf16_to_utf8_with_partial (entry_utf16); + g_free (entry_utf16); + } else { + g_free (entry_utf16); +@@ -1317,6 +1333,9 @@ static char *extract_mhod_string (FConte + } + } + ++ if (entry_utf8 == NULL) ++ return NULL; ++ + if (g_utf8_validate (entry_utf8, -1, NULL)) { + return entry_utf8; + } else { diff --git a/libgpod.spec b/libgpod.spec index e97eb66..04bcddd 100644 --- a/libgpod.spec +++ b/libgpod.spec @@ -3,7 +3,7 @@ Summary: Library to access the contents of an iPod Name: libgpod Version: 0.7.2 -Release: 5%{?dist} +Release: 6%{?dist} License: LGPLv2+ Group: System Environment/Libraries URL: http://www.gtkpod.org/libgpod.html @@ -13,6 +13,8 @@ Patch0: 0001-Use-var-run-hald-as-mount-dir-for-hal-callout.patch # http://gitorious.org/~teuf/libgpod/teuf-sandbox/commit/3847494a513b5ef04d7abbe55c3d95dbcd836ef6 # https://bugzilla.redhat.com/show_bug.cgi?id=517642 Patch1: libgpod-utf16-parsing.patch +# https://bugzilla.redhat.com/show_bug.cgi?id=542176 +Patch2: libgpod-handle-partial-utf16.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root BuildRequires: docbook-style-xsl BuildRequires: glib2-devel @@ -82,6 +84,7 @@ libgpod library. %setup -q %patch0 -p1 -b .selinux %patch1 -p1 -b .utf16 +%patch2 -p1 -b .partial-utf16 # remove execute perms on the python examples as they'll be installed in %doc %{__chmod} -x bindings/python/examples/*.py @@ -141,6 +144,9 @@ libgpod library. %changelog +* Thu Dec 10 2009 Bastien Nocera 0.7.2-6 +- Handle partial UTF-16 strings (#542176) + * Mon Oct 19 2009 Bastien Nocera 0.7.2-5 - Fix UTF-16 string parsing patch again