Skip to content

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
    • Help
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
G
GLib
  • Project
    • Project
    • Details
    • Activity
    • Releases
    • Cycle Analytics
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Charts
  • Issues 1,167
    • Issues 1,167
    • List
    • Board
    • Labels
    • Milestones
  • Merge Requests 47
    • Merge Requests 47
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Charts
  • Registry
    • Registry
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards

Getting colder with our second freeze... it's 3.31.91 release day and string freeze, upload a tarball and lock those strings 🏂

  • GNOME
  • GLib
  • Issues
  • #1364

Closed
Open
Opened Apr 11, 2018 by bugzilla-migration@bugzilla-migration
  • Report abuse
  • New issue
Report abuse New issue

Null pointer dereference in g_markup_parse_context_end_parse()

Submitted by Jin @JsHuang

Link to original bug (#795147)

Description

Created attachment 370763 simple test case to reproduce the bug

Function g_markup_parse_context_end_parse() dosen't call current_element() function carefully. and can cause null pointer dereference error while parsing an malformed input.

The definition of function current_element() is as below:

static inline const gchar* current_element (GMarkupParseContext *context) { return context->tag_stack->data; // context->tag_stack may be NULL; }

This bug resides in gmarkup.c ,near line 1837, in case "STATE_AFTER_CLOSE_TAG_NAME":

1834 case STATE_AFTER_CLOSE_TAG_NAME: 1835 set_error (context, error, G_MARKUP_ERROR_PARSE, 1836 _("Document ended unexpectedly inside the close tag for " 1837 "element '%s'"), current_element (context)); 1838 break;

here set_error is called and use the return value of "current_element (context)" as it's parameter, without checking whether "context->tag_stack" is NULL or not. Parsing invalid data may lead to null pointer dereference.

I think this bug may exits in other place where current_element() is not carefully called, a good way to fix it is to add an assertion in current_element().

The attachment is a simple test case to reproduce it.

credit: ADLab of Venustech

Attachment 370763, "simple test case to reproduce the bug":
current_element.c

Version: 2.56.x

Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
No due date
2
Labels
Bugzilla GMarkup
Assign labels
  • View project labels
Reference: GNOME/glib#1364