mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-03-26 14:50:08 +03:00
Fix potential crash on entities errors
Related to https://bugs.launchpad.net/lxml/+bug/502959 Basically the core of the issue is that if an entity references another entity, then in case we are replacing entities content, we should always do so by copying the referenced content as long as the reference is done within the entity. Otherwise, if for some reason there is a later parsing error that entity content may be freed. Complex scenario exposed by command: thinkpad:~/XML/diveintopython-5.4/xml -> valgrind --db-attach=yes ../../xmllint --loaddtd --noout --noent diveintopython.xml Document references &a; a references &b; we references b content directly in by linking in the a content a has an error further down we free a, freeing the chunk from b Document references &b; after &a; we try to copy b content, but it was freed already => segfault * parser.c: never reference directly entity content without copying if we aren't in the document main entity
This commit is contained in:
parent
3b6d7b9aee
commit
28f5e1a2d6
2
parser.c
2
parser.c
@ -7396,7 +7396,7 @@ xmlParseReference(xmlParserCtxtPtr ctxt) {
|
||||
if (ent->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY)
|
||||
xmlAddEntityReference(ent, firstChild, nw);
|
||||
#endif /* LIBXML_LEGACY_ENABLED */
|
||||
} else if (list == NULL) {
|
||||
} else if ((list == NULL) || (ctxt->inputNr > 0)) {
|
||||
xmlNodePtr nw = NULL, cur, next, last,
|
||||
firstChild = NULL;
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user