After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 666895 - Crash in xmlParseComment when error handler does xmlStopParser
Crash in xmlParseComment when error handler does xmlStopParser
Status: RESOLVED OBSOLETE
Product: libxml2
Classification: Platform
Component: general
2.7.8
Other All
: Normal normal
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2011-12-27 05:24 UTC by Bryan Henderson
Modified: 2021-07-05 13:21 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Bryan Henderson 2011-12-27 05:24:40 UTC
The XML contains a comment which contains "--".  xmlParseComment() recognizes this as an error and calls the SAX error handler.  The error handler calls xmlStopParser().  Upon return, xmlParseComment() continues trying to parse and crashes.  Without the xmlParseComment(), all is well.

The user program actually calls xmlSAXParseFileWithData.  The xmlSAXHandler's 'error' member points to the error handler in question.

See http://mail.gnome.org/archives/xml/2009-December/msg00031.html
Comment 1 Mark Rowe 2013-04-17 02:10:49 UTC
This is still an issue as of libxml2 v2.9. A patch like so appears to fix this without altering the behavior for folks that aren't calling xmlStopParser from within their error handler:

diff --git a/parser.c b/parser.c
index 91f8c90..609236a 100644
--- a/parser.c
+++ b/parser.c
@@ -4995,6 +4995,12 @@ get_more:
                } else
                    xmlFatalErrMsgStr(ctxt, XML_ERR_HYPHEN_IN_COMMENT,
                                      "Double hyphen within comment\n", NULL);
+
+               if (ctxt->instate == XML_PARSER_EOF) {
+                   xmlFree(buf);
+                   return;
+               }
+
                in++;
                ctxt->input->col++;
            }
Comment 2 GNOME Infrastructure Team 2021-07-05 13:21:29 UTC
GNOME is going to shut down bugzilla.gnome.org in favor of gitlab.gnome.org.
As part of that, we are mass-closing older open tickets in bugzilla.gnome.org
which have not seen updates for a longer time (resources are unfortunately
quite limited so not every ticket can get handled).

If you can still reproduce the situation described in this ticket in a recent
and supported software version, then please follow
  https://wiki.gnome.org/GettingInTouch/BugReportingGuidelines
and create a new ticket at
  https://gitlab.gnome.org/GNOME/libxml2/-/issues/

Thank you for your understanding and your help.