Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • G GLib
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 884
    • Issues 884
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 44
    • Merge requests 44
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GNOME
  • GLib
  • Issues
  • #1364
Closed
Open
Created Apr 11, 2018 by Bugzilla@bugzilla-migration💬Reporter

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
Time tracking