Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added data/tests/empty-desc.icc
Binary file not shown.
1 change: 1 addition & 0 deletions data/tests/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ if get_option('installed_tests')
'corrupt-dict.icc',
'crayons.icc',
'DELL-U2713H.bin',
'empty-desc.icc',
'empty.icc',
'example.cmf',
'example.sp',
Expand Down
14 changes: 12 additions & 2 deletions lib/colord/cd-icc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2619,8 +2619,13 @@ cd_icc_get_mluc_data (CdIcc *icc,
country_code,
NULL,
0);
if (text_size == 0)
if (text_size == 0) {
g_set_error_literal (error,
CD_ICC_ERROR,
CD_ICC_ERROR_NO_DATA,
"cmsSigProfile*Tag is empty");
goto out;
}

/* load wide chars */
wtext = g_new (gunichar, text_size);
Expand All @@ -2629,8 +2634,13 @@ cd_icc_get_mluc_data (CdIcc *icc,
country_code,
(wchar_t *) wtext,
text_size);
if (text_size == 0)
if (text_size == 0) {
g_set_error_literal (error,
CD_ICC_ERROR,
CD_ICC_ERROR_NO_DATA,
"cmsSigProfile*Tag is empty");
goto out;
}

/* insert UTF-8 value into locale cache */
text_buffer = g_ucs4_to_utf8 (wtext, -1, NULL, NULL, error);
Expand Down
32 changes: 32 additions & 0 deletions lib/colord/cd-test-private.c
Original file line number Diff line number Diff line change
Expand Up @@ -1446,6 +1446,37 @@ colord_icc_clear_func (void)
g_object_unref (icc);
}

static void
colord_icc_empty_desc_func (void)
{
CdIcc *icc;
const gchar *tmp;
gboolean ret;
g_autofree gchar *filename = NULL;
g_autoptr(GError) error = NULL;
g_autoptr(GFile) file = NULL;

/* empty-desc.icc has a 'desc' (mluc) tag whose single en-US record has
* a string length of zero, so lcms parses it as present-but-empty
* (cmsMLUgetWide() returns 0). Regression test: cd_icc_get_description()
* must return NULL *with* a GError set, never NULL with error==NULL --
* the latter crashed the daemon in cd_main_daemon_method_call() (via
* error->message) when a client loaded the profile with CreateProfile. */
icc = cd_icc_new ();
filename = cd_test_get_filename ("empty-desc.icc");
g_assert (filename != NULL);
file = g_file_new_for_path (filename);
ret = cd_icc_load_file (icc, file, CD_ICC_LOAD_FLAGS_NONE, NULL, &error);
g_assert_no_error (error);
g_assert (ret);

tmp = cd_icc_get_description (icc, NULL, &error);
g_assert_error (error, CD_ICC_ERROR, CD_ICC_ERROR_NO_DATA);
g_assert_cmpstr (tmp, ==, NULL);

g_object_unref (icc);
}

static void
colord_icc_func (void)
{
Expand Down Expand Up @@ -2410,6 +2441,7 @@ main (int argc, char **argv)
g_test_add_func ("/colord/icc{characterization}", colord_icc_characterization_func);
g_test_add_func ("/colord/icc{save}", colord_icc_save_func);
g_test_add_func ("/colord/icc{empty}", colord_icc_empty_func);
g_test_add_func ("/colord/icc{empty-desc}", colord_icc_empty_desc_func);
g_test_add_func ("/colord/icc{corrupt-dict}", colord_icc_corrupt_dict_func);
g_test_add_func ("/colord/icc{clear}", colord_icc_clear_func);
g_test_add_func ("/colord/icc{tags}", colord_icc_tags_func);
Expand Down
Loading