Merge branch 'gtk-fix-issue-4990' into 'main'

Add check for large compose files

Closes #4990

See merge request GNOME/gtk!6195
This commit is contained in:
Matthias Clasen 2023-07-20 17:39:06 +00:00
commit 99d6a15049
3 changed files with 34525 additions and 0 deletions

View File

@ -980,6 +980,7 @@ parser_get_compose_table (GtkComposeParser *parser)
current_first = (guint16)sequence[0];
data[first_pos] = (guint16)sequence[0];
for (i = 1; i < index_rowstride; i++)
data[first_pos + i] = rest_pos;
}
@ -998,6 +999,14 @@ parser_get_compose_table (GtkComposeParser *parser)
rest_pos += len;
if (rest_pos >= 0x8000)
{
g_warning ("GTK can't handle compose tables this large (%s)", parser->compose_file ? parser->compose_file : "");
g_free (data);
g_string_free (char_data, TRUE);
return NULL;
}
for (i = len + 1; i < index_rowstride; i++)
data[first_pos + i] = rest_pos;

34493
testsuite/gtk/compose/large Normal file

File diff suppressed because it is too large Load Diff

View File

@ -405,6 +405,28 @@ match_algorithmic (void)
g_string_free (output, TRUE);
}
static void
compose_table_large (void)
{
if (g_test_subprocess ())
{
char *file;
GtkComposeTable *table;
file = g_test_build_filename (G_TEST_DIST, "compose", "large", NULL);
table = gtk_compose_table_parse (file, NULL);
g_assert_nonnull (table);
g_free (file);
return;
}
g_test_trap_subprocess (NULL, 0, 0);
g_test_trap_assert_stderr ("*can't handle compose tables this large*");
g_test_trap_assert_failed ();
}
int
main (int argc, char *argv[])
{
@ -444,6 +466,7 @@ main (int argc, char *argv[])
g_test_add_func ("/compose-table/match", compose_table_match);
g_test_add_func ("/compose-table/match-builtin", compose_table_match_builtin);
g_test_add_func ("/compose-table/match-algorithmic", match_algorithmic);
g_test_add_func ("/compose-table/large", compose_table_large);
return g_test_run ();
}