New upstream version

- Add some translated profile descriptions for the CMYK profiles
- Add the FOGRA45L and FOGRA47L CMYK and eciRGBv1 profiles
- Check the generated CCMX matrix for invalid data
- Do not print a warning if the DBus property does not exist
- Ensure mbstowcs() has an LC_CTYPE of 'en_US.UTF-8'
- Always write C-locale floating point values in IT8 files
- Initialize the value of the CCMX matrix
- Never promote localized v2 ICC profiles to v4
- Rename ISOnewspaper26 to IFRA26S_2004_newsprint
This commit is contained in:
Richard Hughes 2013-04-16 12:18:48 +01:00
parent fa16efc21e
commit 7778552baa
4 changed files with 19 additions and 170 deletions

1
.gitignore vendored
View File

@ -30,3 +30,4 @@
/colord-0.1.30.tar.xz
/colord-0.1.31.tar.xz
/colord-0.1.32.tar.xz
/colord-0.1.33.tar.xz

View File

@ -1,163 +0,0 @@
diff --git a/lib/colord/cd-icc.c b/lib/colord/cd-icc.c
index c3f3d87..2554d78 100644
--- a/lib/colord/cd-icc.c
+++ b/lib/colord/cd-icc.c
@@ -28,6 +28,7 @@
#include <glib.h>
#include <lcms2.h>
+#include <locale.h>
#include <string.h>
#include <stdlib.h>
@@ -813,10 +814,14 @@ out:
static wchar_t *
utf8_to_wchar_t (const char *src)
{
+ const gchar *orig_locale;
gssize len;
gssize converted;
wchar_t *buf = NULL;
+ /* switch the locale to a known UTF-8 LC_CTYPE */
+ orig_locale = setlocale (LC_CTYPE, NULL);
+ setlocale (LC_CTYPE, "en_US.UTF-8");
len = mbstowcs (NULL, src, 0);
if (len < 0) {
g_warning ("Invalid UTF-8 in string %s", src);
@@ -828,28 +833,49 @@ utf8_to_wchar_t (const char *src)
g_assert (converted != -1);
buf[converted] = '\0';
out:
+ setlocale (LC_CTYPE, orig_locale);
return buf;
}
/**
- * _cmsDictAddEntryAscii:
+ * cd_util_write_dict_entry:
**/
-static cmsBool
-_cmsDictAddEntryAscii (cmsHANDLE dict,
- const gchar *key,
- const gchar *value)
+static gboolean
+cd_util_write_dict_entry (cmsHANDLE dict,
+ const gchar *key,
+ const gchar *value,
+ GError **error)
{
- cmsBool ret = FALSE;
+ gboolean ret = FALSE;
wchar_t *mb_key = NULL;
wchar_t *mb_value = NULL;
mb_key = utf8_to_wchar_t (key);
- if (mb_key == NULL)
+ if (mb_key == NULL) {
+ g_set_error (error,
+ CD_ICC_ERROR,
+ CD_ICC_ERROR_FAILED_TO_SAVE,
+ "Failed to write invalid ASCII key: '%s'",
+ key);
goto out;
+ }
mb_value = utf8_to_wchar_t (value);
- if (mb_value == NULL)
+ if (mb_value == NULL) {
+ g_set_error (error,
+ CD_ICC_ERROR,
+ CD_ICC_ERROR_FAILED_TO_SAVE,
+ "Failed to write invalid ASCII value: '%s'",
+ value);
goto out;
+ }
ret = cmsDictAddEntry (dict, mb_key, mb_value, NULL, NULL);
+ if (!ret) {
+ g_set_error_literal (error,
+ CD_ICC_ERROR,
+ CD_ICC_ERROR_FAILED_TO_SAVE,
+ "Failed to write dict entry");
+ goto out;
+ }
out:
g_free (mb_key);
g_free (mb_value);
@@ -889,8 +915,11 @@ cd_util_mlu_object_parse (const gchar *locale, const gchar *utf8_text)
/* untranslated version */
if (locale == NULL || locale[0] == '\0') {
+ wtext = utf8_to_wchar_t (utf8_text);
+ if (wtext == NULL)
+ goto out;
obj = g_new0 (CdMluObject, 1);
- obj->wtext = utf8_to_wchar_t (utf8_text);
+ obj->wtext = wtext;
goto out;
}
@@ -946,6 +975,7 @@ cd_util_write_tag_localized (CdIcc *icc,
CdMluObject *obj;
cmsMLU *mlu = NULL;
const gchar *locale;
+ const gchar *value;
gboolean ret = TRUE;
GList *keys;
GList *l;
@@ -957,10 +987,13 @@ cd_util_write_tag_localized (CdIcc *icc,
array = g_ptr_array_new_with_free_func (cd_util_mlu_object_free);
for (l = keys; l != NULL; l = l->next) {
locale = l->data;
- obj = cd_util_mlu_object_parse (locale,
- g_hash_table_lookup (hash, locale));
- if (obj == NULL)
+ value = g_hash_table_lookup (hash, locale);
+ obj = cd_util_mlu_object_parse (locale, value);
+ if (obj == NULL) {
+ g_warning ("failed to parse localized text: %s[%s]",
+ value, locale);
continue;
+ }
g_ptr_array_add (array, obj);
}
@@ -1053,7 +1086,7 @@ cd_icc_save_file (CdIcc *icc,
GError *error_local = NULL;
GList *l;
GList *md_keys = NULL;
- gsize length;
+ gsize length = 0;
guint i;
g_return_val_if_fail (CD_IS_ICC (icc), FALSE);
@@ -1089,7 +1122,10 @@ cd_icc_save_file (CdIcc *icc,
for (l = md_keys; l != NULL; l = l->next) {
key = l->data;
value = g_hash_table_lookup (priv->metadata, key);
- _cmsDictAddEntryAscii (dict, key, value);
+ ret = cd_util_write_dict_entry (dict, key,
+ value, error);
+ if (!ret)
+ goto out;
}
}
ret = cmsWriteTag (priv->lcms_profile, cmsSigMetaTag, dict);
@@ -1152,6 +1188,18 @@ cd_icc_save_file (CdIcc *icc,
goto out;
}
+ /* sanity check to 16Mb */
+ if (length == 0 || length > 16 * 1024 * 1024) {
+ ret = FALSE;
+ g_set_error (error,
+ CD_ICC_ERROR,
+ CD_ICC_ERROR_FAILED_TO_SAVE,
+ "failed to save ICC file, requested %" G_GSIZE_FORMAT
+ "bytes and limit is 16Mb",
+ length);
+ goto out;
+ }
+
/* allocate and get profile data */
data = g_new0 (gchar, length);
ret = cmsSaveProfileToMem (priv->lcms_profile,

View File

@ -18,15 +18,12 @@
Summary: Color daemon
Name: colord
Version: 0.1.32
Version: 0.1.33
Release: 1%{?dist}
License: GPLv2+ and LGPLv2+
URL: http://www.freedesktop.org/software/colord/
Source0: http://www.freedesktop.org/software/colord/releases/%{name}-%{version}.tar.xz
# Update to master branch
Patch0: colord-master.patch
BuildRequires: dbus-devel
BuildRequires: docbook-utils
BuildRequires: gettext
@ -106,7 +103,6 @@ This may be useful for CMYK soft-proofing or for extra device support.
%prep
%setup -q
%patch0 -p1 -b .master
%build
# we can't use _hardened_build here, see
@ -227,8 +223,10 @@ glib-compile-schemas %{_datadir}/glib-2.0/schemas &> /dev/null || :
%{_icccolordir}/colord/FOGRA29L_uncoated.icc
%{_icccolordir}/colord/FOGRA30L_uncoated_yellowish.icc
%{_icccolordir}/colord/FOGRA40L_SC_paper.icc
%{_icccolordir}/colord/FOGRA45L_lwc.icc
%{_icccolordir}/colord/FOGRA47L_uncoated.icc
%{_icccolordir}/colord/GRACoL*.icc
%{_icccolordir}/colord/ISOnewspaper26.icc
%{_icccolordir}/colord/IFRA26S_2004_newsprint.icc
%{_icccolordir}/colord/SNAP*.icc
%{_icccolordir}/colord/SWOP*.icc
%endif
@ -241,6 +239,7 @@ glib-compile-schemas %{_datadir}/glib-2.0/schemas &> /dev/null || :
%{_icccolordir}/colord/CIE-RGB.icc
%{_icccolordir}/colord/ColorMatchRGB.icc
%{_icccolordir}/colord/DonRGB4.icc
%{_icccolordir}/colord/ECI-RGBv1.icc
%{_icccolordir}/colord/ECI-RGBv2.icc
%{_icccolordir}/colord/EktaSpacePS5.icc
%{_icccolordir}/colord/Gamma*.icc
@ -264,6 +263,18 @@ glib-compile-schemas %{_datadir}/glib-2.0/schemas &> /dev/null || :
%{_datadir}/gtk-doc/html/colord/*
%changelog
* Tue Apr 16 2013 Richard Hughes <richard@hughsie.com> 0.1.33-1
- New upstream version
- Add some translated profile descriptions for the CMYK profiles
- Add the FOGRA45L and FOGRA47L CMYK and eciRGBv1 profiles
- Check the generated CCMX matrix for invalid data
- Do not print a warning if the DBus property does not exist
- Ensure mbstowcs() has an LC_CTYPE of 'en_US.UTF-8'
- Always write C-locale floating point values in IT8 files
- Initialize the value of the CCMX matrix
- Never promote localized v2 ICC profiles to v4
- Rename ISOnewspaper26 to IFRA26S_2004_newsprint
* Thu Mar 28 2013 Richard Hughes <richard@hughsie.com> 0.1.32-1
- New upstream version
- Add a new tool 'cd-iccdump' that can dump V4 and V2 profiles

View File

@ -1 +1 @@
fecd86425982d48b1545fe30e38a381d colord-0.1.32.tar.xz
384f1be4e23ac0dbf1977224aac306c1 colord-0.1.33.tar.xz