Reject compose tables that are too large
authorMatthias Clasen <mclasen@redhat.com>
Mon, 2 May 2022 08:03:45 +0000 (16:03 +0800)
committerMatthias Clasen <mclasen@redhat.com>
Mon, 2 May 2022 08:03:45 +0000 (16:03 +0800)
The fixed-size format we use currently can only handle up
to 32768 bytes of string data. If a compose file contains
more, reject it with a warning.

Fixes: #4873
gtk/gtkcomposetable.c

index 4ec357fc97e6fd4a88974d7678f0f81455926542..eda1e5ad5b00f0ce5368484a239c4af1fa23c693 100644 (file)
@@ -942,7 +942,12 @@ parser_get_compose_table (GtkComposeParser *parser)
           if (char_data->len > 0)
             g_string_append_c (char_data, 0);
 
-          g_assert (char_data->len < 0x8000);
+          if (char_data->len >= 0x8000)
+            {
+              g_warning ("GTK can't handle compose tables this large (%s)", parser->compose_file ? parser->compose_file : "");
+              g_string_free (char_data, TRUE);
+              return NULL;
+            }
 
           encoded_value = (guint16) (char_data->len | 0x8000);
           g_string_append (char_data, value);