mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-02-15 17:57:33 +03:00
Avoid building recursive entities
For https://bugzilla.gnome.org/show_bug.cgi?id=762100 When we detect a recusive entity we should really not build the associated data, moreover if someone bypass libxml2 fatal errors and still tries to serialize a broken entity make sure we don't risk to get ito a recursion * parser.c: xmlParserEntityCheck() don't build if entity loop were found and remove the associated text content * tree.c: xmlStringGetNodeList() avoid a potential recursion
This commit is contained in:
parent
0bcd05c5cd
commit
bdd66182ef
6
parser.c
6
parser.c
@ -138,7 +138,8 @@ xmlParserEntityCheck(xmlParserCtxtPtr ctxt, size_t size,
|
||||
* entities problems
|
||||
*/
|
||||
if ((ent != NULL) && (ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) &&
|
||||
(ent->content != NULL) && (ent->checked == 0)) {
|
||||
(ent->content != NULL) && (ent->checked == 0) &&
|
||||
(ctxt->errNo != XML_ERR_ENTITY_LOOP)) {
|
||||
unsigned long oldnbent = ctxt->nbentities;
|
||||
xmlChar *rep;
|
||||
|
||||
@ -148,6 +149,9 @@ xmlParserEntityCheck(xmlParserCtxtPtr ctxt, size_t size,
|
||||
rep = xmlStringDecodeEntities(ctxt, ent->content,
|
||||
XML_SUBSTITUTE_REF, 0, 0, 0);
|
||||
--ctxt->depth;
|
||||
if (ctxt->errNo == XML_ERR_ENTITY_LOOP) {
|
||||
ent->content[0] = 0;
|
||||
}
|
||||
|
||||
ent->checked = (ctxt->nbentities - oldnbent + 1) * 2;
|
||||
if (rep != NULL) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user