1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-10-26 12:25:09 +03:00

Stop parser on unsupported encodings

Otherwise, the push parser can loop infinitely in recover mode.

Found with libFuzzer.
This commit is contained in:
Nick Wellnhofer 2017-06-07 16:07:33 +02:00
parent 030b1f7a27
commit 0db8dc9ddc

View File

@ -1101,8 +1101,10 @@ xmlSwitchEncoding(xmlParserCtxtPtr ctxt, xmlCharEncoding enc)
break;
}
}
if (handler == NULL)
if (handler == NULL) {
xmlStopParser(ctxt);
return(-1);
}
ctxt->charset = XML_CHAR_ENCODING_UTF8;
ret = xmlSwitchToEncodingInt(ctxt, handler, len);
if ((ret < 0) || (ctxt->errNo == XML_I18N_CONV_FAILED)) {