From 0911f2e9078ffd83817c00b061506bdf0aae8fa5 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 5 Jun 2007 19:14:46 +0000 Subject: [PATCH] Don't assume the string is valid UTF-8, since it may be user data. 2007-06-05 Matthias Clasen * glib/gkeyfile.c (g_key_file_is_key_name): (g_key_file_is_group_name): Don't assume the string is valid UTF-8, since it may be user data. (#444161, Ben Combee) svn path=/trunk/; revision=5537 --- ChangeLog | 6 ++++++ glib/gkeyfile.c | 16 ++++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4e622a0..a824ff0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2007-06-05 Matthias Clasen + + * glib/gkeyfile.c (g_key_file_is_key_name): + (g_key_file_is_group_name): Don't assume the string is + valid UTF-8, since it may be user data. (#444161, Ben Combee) + 2007-06-05 Behdad Esfahbod * glib/gutf8.c: Add not to g_utf8_get_char_validated() about diff --git a/glib/gkeyfile.c b/glib/gkeyfile.c index d3bb729..0e144c0 100644 --- a/glib/gkeyfile.c +++ b/glib/gkeyfile.c @@ -3267,7 +3267,7 @@ g_key_file_is_group_name (const gchar *name) p = q = (gchar *) name; while (*q && *q != ']' && *q != '[' && !g_ascii_iscntrl (*q)) - q = g_utf8_next_char (q); + q = g_utf8_find_next_char (q, NULL); if (*q != '\0' || q == p) return FALSE; @@ -3288,7 +3288,7 @@ g_key_file_is_key_name (const gchar *name) * since gnome-vfs uses mime-types as keys in its cache. */ while (*q && *q != '=' && *q != '[' && *q != ']') - q = g_utf8_next_char (q); + q = g_utf8_find_next_char (q, NULL); /* No empty keys, please */ if (q == p) @@ -3305,8 +3305,8 @@ g_key_file_is_key_name (const gchar *name) if (*q == '[') { q++; - while (*q && (g_unichar_isalnum (g_utf8_get_char (q)) || *q == '-' || *q == '_' || *q == '.' || *q == '@')) - q = g_utf8_next_char (q); + while (*q && (g_unichar_isalnum (g_utf8_get_char_validated (q, -1)) || *q == '-' || *q == '_' || *q == '.' || *q == '@')) + q = g_utf8_find_next_char (q, NULL); if (*q != ']') return FALSE; @@ -3335,15 +3335,15 @@ g_key_file_line_is_group (const gchar *line) p++; while (*p && *p != ']') - p = g_utf8_next_char (p); + p = g_utf8_find_next_char (p, NULL); if (*p != ']') return FALSE; /* silently accept whitespace after the ] */ - p = g_utf8_next_char (p); + p = g_utf8_find_next_char (p, NULL); while (*p == ' ' || *p == '\t') - p = g_utf8_next_char (p); + p = g_utf8_find_next_char (p, NULL); if (*p) return FALSE; @@ -3565,7 +3565,7 @@ g_key_file_parse_value_as_integer (GKeyFile *key_file, GError **error) { gchar *end_of_valid_int; - glong long_value; + glong long_value; gint int_value; errno = 0; -- 2.7.4