mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-10-02 11:56:38 +02:00
keep entity name in a newly alocated buffer to prevent segfaulting on
Wed Aug 7 17:38:16 2002 Tim Janik <timj@gtk.org> * glib/gmarkup.c (unescape_text): keep entity name in a newly alocated buffer to prevent segfaulting on entity names which are longer than 5 characters.
This commit is contained in:
@@ -1,3 +1,9 @@
|
|||||||
|
Wed Aug 7 17:38:16 2002 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* glib/gmarkup.c (unescape_text): keep entity name in
|
||||||
|
a newly alocated buffer to prevent segfaulting on entity
|
||||||
|
names which are longer than 5 characters.
|
||||||
|
|
||||||
2002-08-06 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
2002-08-06 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||||
|
|
||||||
* glib/gmain.c: Factor out g_main_context_init_pipe from
|
* glib/gmain.c: Factor out g_main_context_init_pipe from
|
||||||
|
@@ -1,3 +1,9 @@
|
|||||||
|
Wed Aug 7 17:38:16 2002 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* glib/gmarkup.c (unescape_text): keep entity name in
|
||||||
|
a newly alocated buffer to prevent segfaulting on entity
|
||||||
|
names which are longer than 5 characters.
|
||||||
|
|
||||||
2002-08-06 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
2002-08-06 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||||
|
|
||||||
* glib/gmain.c: Factor out g_main_context_init_pipe from
|
* glib/gmain.c: Factor out g_main_context_init_pipe from
|
||||||
|
@@ -1,3 +1,9 @@
|
|||||||
|
Wed Aug 7 17:38:16 2002 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* glib/gmarkup.c (unescape_text): keep entity name in
|
||||||
|
a newly alocated buffer to prevent segfaulting on entity
|
||||||
|
names which are longer than 5 characters.
|
||||||
|
|
||||||
2002-08-06 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
2002-08-06 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||||
|
|
||||||
* glib/gmain.c: Factor out g_main_context_init_pipe from
|
* glib/gmain.c: Factor out g_main_context_init_pipe from
|
||||||
|
@@ -1,3 +1,9 @@
|
|||||||
|
Wed Aug 7 17:38:16 2002 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* glib/gmarkup.c (unescape_text): keep entity name in
|
||||||
|
a newly alocated buffer to prevent segfaulting on entity
|
||||||
|
names which are longer than 5 characters.
|
||||||
|
|
||||||
2002-08-06 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
2002-08-06 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||||
|
|
||||||
* glib/gmain.c: Factor out g_main_context_init_pipe from
|
* glib/gmain.c: Factor out g_main_context_init_pipe from
|
||||||
|
@@ -1,3 +1,9 @@
|
|||||||
|
Wed Aug 7 17:38:16 2002 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* glib/gmarkup.c (unescape_text): keep entity name in
|
||||||
|
a newly alocated buffer to prevent segfaulting on entity
|
||||||
|
names which are longer than 5 characters.
|
||||||
|
|
||||||
2002-08-06 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
2002-08-06 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||||
|
|
||||||
* glib/gmain.c: Factor out g_main_context_init_pipe from
|
* glib/gmain.c: Factor out g_main_context_init_pipe from
|
||||||
|
@@ -1,3 +1,9 @@
|
|||||||
|
Wed Aug 7 17:38:16 2002 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* glib/gmarkup.c (unescape_text): keep entity name in
|
||||||
|
a newly alocated buffer to prevent segfaulting on entity
|
||||||
|
names which are longer than 5 characters.
|
||||||
|
|
||||||
2002-08-06 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
2002-08-06 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||||
|
|
||||||
* glib/gmain.c: Factor out g_main_context_init_pipe from
|
* glib/gmain.c: Factor out g_main_context_init_pipe from
|
||||||
|
@@ -1,3 +1,9 @@
|
|||||||
|
Wed Aug 7 17:38:16 2002 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* glib/gmarkup.c (unescape_text): keep entity name in
|
||||||
|
a newly alocated buffer to prevent segfaulting on entity
|
||||||
|
names which are longer than 5 characters.
|
||||||
|
|
||||||
2002-08-06 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
2002-08-06 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||||
|
|
||||||
* glib/gmain.c: Factor out g_main_context_init_pipe from
|
* glib/gmain.c: Factor out g_main_context_init_pipe from
|
||||||
|
@@ -367,7 +367,6 @@ unescape_text (GMarkupParseContext *context,
|
|||||||
gchar **unescaped,
|
gchar **unescaped,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
#define MAX_ENT_LEN 5
|
|
||||||
GString *str;
|
GString *str;
|
||||||
const gchar *p;
|
const gchar *p;
|
||||||
UnescapeState state;
|
UnescapeState state;
|
||||||
@@ -450,11 +449,6 @@ unescape_text (GMarkupParseContext *context,
|
|||||||
|
|
||||||
case USTATE_INSIDE_ENTITY_NAME:
|
case USTATE_INSIDE_ENTITY_NAME:
|
||||||
{
|
{
|
||||||
gchar buf[MAX_ENT_LEN+1] = {
|
|
||||||
'\0', '\0', '\0', '\0', '\0', '\0'
|
|
||||||
};
|
|
||||||
gchar *dest;
|
|
||||||
|
|
||||||
while (p != text_end)
|
while (p != text_end)
|
||||||
{
|
{
|
||||||
if (*p == ';')
|
if (*p == ';')
|
||||||
@@ -479,31 +473,22 @@ unescape_text (GMarkupParseContext *context,
|
|||||||
{
|
{
|
||||||
if (p != text_end)
|
if (p != text_end)
|
||||||
{
|
{
|
||||||
const gchar *src;
|
gchar *ent = g_strndup (start, p - start);
|
||||||
|
|
||||||
src = start;
|
|
||||||
dest = buf;
|
|
||||||
while (src != p)
|
|
||||||
{
|
|
||||||
*dest = *src;
|
|
||||||
++dest;
|
|
||||||
++src;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* move to after semicolon */
|
/* move to after semicolon */
|
||||||
p = g_utf8_next_char (p);
|
p = g_utf8_next_char (p);
|
||||||
start = p;
|
start = p;
|
||||||
state = USTATE_INSIDE_TEXT;
|
state = USTATE_INSIDE_TEXT;
|
||||||
|
|
||||||
if (strcmp (buf, "lt") == 0)
|
if (strcmp (ent, "lt") == 0)
|
||||||
g_string_append_c (str, '<');
|
g_string_append_c (str, '<');
|
||||||
else if (strcmp (buf, "gt") == 0)
|
else if (strcmp (ent, "gt") == 0)
|
||||||
g_string_append_c (str, '>');
|
g_string_append_c (str, '>');
|
||||||
else if (strcmp (buf, "amp") == 0)
|
else if (strcmp (ent, "amp") == 0)
|
||||||
g_string_append_c (str, '&');
|
g_string_append_c (str, '&');
|
||||||
else if (strcmp (buf, "quot") == 0)
|
else if (strcmp (ent, "quot") == 0)
|
||||||
g_string_append_c (str, '"');
|
g_string_append_c (str, '"');
|
||||||
else if (strcmp (buf, "apos") == 0)
|
else if (strcmp (ent, "apos") == 0)
|
||||||
g_string_append_c (str, '\'');
|
g_string_append_c (str, '\'');
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -511,8 +496,9 @@ unescape_text (GMarkupParseContext *context,
|
|||||||
p, text_end,
|
p, text_end,
|
||||||
G_MARKUP_ERROR_PARSE,
|
G_MARKUP_ERROR_PARSE,
|
||||||
_("Entity name '%s' is not known"),
|
_("Entity name '%s' is not known"),
|
||||||
buf);
|
ent);
|
||||||
}
|
}
|
||||||
|
g_free (ent);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -666,8 +652,6 @@ unescape_text (GMarkupParseContext *context,
|
|||||||
*unescaped = g_string_free (str, FALSE);
|
*unescaped = g_string_free (str, FALSE);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef MAX_ENT_LEN
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
Reference in New Issue
Block a user