mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-26 15:36:14 +01:00
Don't assume the string is valid UTF-8, since it may be user data.
2007-06-05 Matthias Clasen <mclasen@redhat.com> * 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
This commit is contained in:
parent
ed6b059bc2
commit
0911f2e907
@ -1,3 +1,9 @@
|
|||||||
|
2007-06-05 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* 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 <behdad@gnome.org>
|
2007-06-05 Behdad Esfahbod <behdad@gnome.org>
|
||||||
|
|
||||||
* glib/gutf8.c: Add not to g_utf8_get_char_validated() about
|
* glib/gutf8.c: Add not to g_utf8_get_char_validated() about
|
||||||
|
@ -3267,7 +3267,7 @@ g_key_file_is_group_name (const gchar *name)
|
|||||||
|
|
||||||
p = q = (gchar *) name;
|
p = q = (gchar *) name;
|
||||||
while (*q && *q != ']' && *q != '[' && !g_ascii_iscntrl (*q))
|
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)
|
if (*q != '\0' || q == p)
|
||||||
return FALSE;
|
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.
|
* since gnome-vfs uses mime-types as keys in its cache.
|
||||||
*/
|
*/
|
||||||
while (*q && *q != '=' && *q != '[' && *q != ']')
|
while (*q && *q != '=' && *q != '[' && *q != ']')
|
||||||
q = g_utf8_next_char (q);
|
q = g_utf8_find_next_char (q, NULL);
|
||||||
|
|
||||||
/* No empty keys, please */
|
/* No empty keys, please */
|
||||||
if (q == p)
|
if (q == p)
|
||||||
@ -3305,8 +3305,8 @@ g_key_file_is_key_name (const gchar *name)
|
|||||||
if (*q == '[')
|
if (*q == '[')
|
||||||
{
|
{
|
||||||
q++;
|
q++;
|
||||||
while (*q && (g_unichar_isalnum (g_utf8_get_char (q)) || *q == '-' || *q == '_' || *q == '.' || *q == '@'))
|
while (*q && (g_unichar_isalnum (g_utf8_get_char_validated (q, -1)) || *q == '-' || *q == '_' || *q == '.' || *q == '@'))
|
||||||
q = g_utf8_next_char (q);
|
q = g_utf8_find_next_char (q, NULL);
|
||||||
|
|
||||||
if (*q != ']')
|
if (*q != ']')
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -3335,15 +3335,15 @@ g_key_file_line_is_group (const gchar *line)
|
|||||||
p++;
|
p++;
|
||||||
|
|
||||||
while (*p && *p != ']')
|
while (*p && *p != ']')
|
||||||
p = g_utf8_next_char (p);
|
p = g_utf8_find_next_char (p, NULL);
|
||||||
|
|
||||||
if (*p != ']')
|
if (*p != ']')
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* silently accept whitespace after the ] */
|
/* silently accept whitespace after the ] */
|
||||||
p = g_utf8_next_char (p);
|
p = g_utf8_find_next_char (p, NULL);
|
||||||
while (*p == ' ' || *p == '\t')
|
while (*p == ' ' || *p == '\t')
|
||||||
p = g_utf8_next_char (p);
|
p = g_utf8_find_next_char (p, NULL);
|
||||||
|
|
||||||
if (*p)
|
if (*p)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -3565,7 +3565,7 @@ g_key_file_parse_value_as_integer (GKeyFile *key_file,
|
|||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gchar *end_of_valid_int;
|
gchar *end_of_valid_int;
|
||||||
glong long_value;
|
glong long_value;
|
||||||
gint int_value;
|
gint int_value;
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user