| Index: third_party/libxml/src/parser.c
|
| diff --git a/third_party/libxml/src/parser.c b/third_party/libxml/src/parser.c
|
| index 1d9396786ba7eca5d8e985d18e2679398243acd4..0677030c2d9607eea36c424bf4f42f81d22245f2 100644
|
| --- a/third_party/libxml/src/parser.c
|
| +++ b/third_party/libxml/src/parser.c
|
| @@ -94,6 +94,8 @@ static xmlParserCtxtPtr
|
| xmlCreateEntityParserCtxtInternal(const xmlChar *URL, const xmlChar *ID,
|
| const xmlChar *base, xmlParserCtxtPtr pctx);
|
|
|
| +static void xmlHaltParser(xmlParserCtxtPtr ctxt);
|
| +
|
| /************************************************************************
|
| * *
|
| * Arbitrary limits set in the parser. See XML_PARSE_HUGE *
|
| @@ -1771,7 +1773,7 @@ nodePush(xmlParserCtxtPtr ctxt, xmlNodePtr value)
|
| xmlFatalErrMsgInt(ctxt, XML_ERR_INTERNAL_ERROR,
|
| "Excessive depth in document: %d use XML_PARSE_HUGE option\n",
|
| xmlParserMaxDepth);
|
| - ctxt->instate = XML_PARSER_EOF;
|
| + xmlHaltParser(ctxt);
|
| return(-1);
|
| }
|
| ctxt->nodeTab[ctxt->nodeNr] = value;
|
| @@ -2073,9 +2075,16 @@ static void xmlGROW (xmlParserCtxtPtr ctxt) {
|
| ((ctxt->input->buf) && (ctxt->input->buf->readcallback != (xmlInputReadCallback) xmlNop)) &&
|
| ((ctxt->options & XML_PARSE_HUGE) == 0)) {
|
| xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR, "Huge input lookup");
|
| - ctxt->instate = XML_PARSER_EOF;
|
| + xmlHaltParser(ctxt);
|
| + return;
|
| }
|
| xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
|
| + if ((ctxt->input->cur > ctxt->input->end) ||
|
| + (ctxt->input->cur < ctxt->input->base)) {
|
| + xmlHaltParser(ctxt);
|
| + xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR, "cur index out of bound");
|
| + return;
|
| + }
|
| if ((ctxt->input->cur != NULL) && (*ctxt->input->cur == 0) &&
|
| (xmlParserInputGrow(ctxt->input, INPUT_CHUNK) <= 0))
|
| xmlPopInput(ctxt);
|
| @@ -2151,7 +2160,8 @@ xmlSkipBlankChars(xmlParserCtxtPtr ctxt) {
|
| int cur;
|
| do {
|
| cur = CUR;
|
| - while (IS_BLANK_CH(cur)) { /* CHECKED tstblanks.xml */
|
| + while ((IS_BLANK_CH(cur) && /* CHECKED tstblanks.xml */
|
| + (ctxt->instate != XML_PARSER_EOF))) {
|
| NEXT;
|
| cur = CUR;
|
| res++;
|
| @@ -2165,7 +2175,8 @@ xmlSkipBlankChars(xmlParserCtxtPtr ctxt) {
|
| * Need to handle support of entities branching here
|
| */
|
| if (*ctxt->input->cur == '%') xmlParserHandlePEReference(ctxt);
|
| - } while (IS_BLANK(cur)); /* CHECKED tstblanks.xml */
|
| + } while ((IS_BLANK(cur)) && /* CHECKED tstblanks.xml */
|
| + (ctxt->instate != XML_PARSER_EOF));
|
| }
|
| return(res);
|
| }
|
| @@ -2806,6 +2817,10 @@ xmlStringLenDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int len,
|
| 0, 0, 0);
|
| ctxt->depth--;
|
|
|
| + if ((ctxt->lastError.code == XML_ERR_ENTITY_LOOP) ||
|
| + (ctxt->lastError.code == XML_ERR_INTERNAL_ERROR))
|
| + goto int_error;
|
| +
|
| if (rep != NULL) {
|
| current = rep;
|
| while (*current != 0) { /* non input consuming loop */
|
| @@ -3491,7 +3506,14 @@ xmlParseNCNameComplex(xmlParserCtxtPtr ctxt) {
|
| c = CUR_CHAR(l);
|
| if (c == 0) {
|
| count = 0;
|
| + /*
|
| + * when shrinking to extend the buffer we really need to preserve
|
| + * the part of the name we already parsed. Hence rolling back
|
| + * by current lenght.
|
| + */
|
| + ctxt->input->cur -= l;
|
| GROW;
|
| + ctxt->input->cur += l;
|
| if (ctxt->instate == XML_PARSER_EOF)
|
| return(NULL);
|
| end = ctxt->input->cur;
|
| @@ -3523,7 +3545,7 @@ xmlParseNCNameComplex(xmlParserCtxtPtr ctxt) {
|
|
|
| static const xmlChar *
|
| xmlParseNCName(xmlParserCtxtPtr ctxt) {
|
| - const xmlChar *in;
|
| + const xmlChar *in, *e;
|
| const xmlChar *ret;
|
| int count = 0;
|
|
|
| @@ -3535,16 +3557,19 @@ xmlParseNCName(xmlParserCtxtPtr ctxt) {
|
| * Accelerator for simple ASCII names
|
| */
|
| in = ctxt->input->cur;
|
| - if (((*in >= 0x61) && (*in <= 0x7A)) ||
|
| - ((*in >= 0x41) && (*in <= 0x5A)) ||
|
| - (*in == '_')) {
|
| + e = ctxt->input->end;
|
| + if ((((*in >= 0x61) && (*in <= 0x7A)) ||
|
| + ((*in >= 0x41) && (*in <= 0x5A)) ||
|
| + (*in == '_')) && (in < e)) {
|
| in++;
|
| - while (((*in >= 0x61) && (*in <= 0x7A)) ||
|
| - ((*in >= 0x41) && (*in <= 0x5A)) ||
|
| - ((*in >= 0x30) && (*in <= 0x39)) ||
|
| - (*in == '_') || (*in == '-') ||
|
| - (*in == '.'))
|
| + while ((((*in >= 0x61) && (*in <= 0x7A)) ||
|
| + ((*in >= 0x41) && (*in <= 0x5A)) ||
|
| + ((*in >= 0x30) && (*in <= 0x39)) ||
|
| + (*in == '_') || (*in == '-') ||
|
| + (*in == '.')) && (in < e))
|
| in++;
|
| + if (in >= e)
|
| + goto complex;
|
| if ((*in > 0) && (*in < 0x80)) {
|
| count = in - ctxt->input->cur;
|
| if ((count > XML_MAX_NAME_LENGTH) &&
|
| @@ -3562,6 +3587,7 @@ xmlParseNCName(xmlParserCtxtPtr ctxt) {
|
| return(ret);
|
| }
|
| }
|
| +complex:
|
| return(xmlParseNCNameComplex(ctxt));
|
| }
|
|
|
| @@ -5658,6 +5684,7 @@ xmlParseEntityDecl(xmlParserCtxtPtr ctxt) {
|
| if (RAW != '>') {
|
| xmlFatalErrMsgStr(ctxt, XML_ERR_ENTITY_NOT_FINISHED,
|
| "xmlParseEntityDecl: entity %s not terminated\n", name);
|
| + xmlHaltParser(ctxt);
|
| } else {
|
| if (input != ctxt->input) {
|
| xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
|
| @@ -6769,6 +6796,8 @@ xmlParseConditionalSections(xmlParserCtxtPtr ctxt) {
|
| SKIP_BLANKS;
|
| if (RAW != '[') {
|
| xmlFatalErr(ctxt, XML_ERR_CONDSEC_INVALID, NULL);
|
| + xmlHaltParser(ctxt);
|
| + return;
|
| } else {
|
| if (ctxt->input->id != id) {
|
| xmlValidityError(ctxt, XML_ERR_ENTITY_BOUNDARY,
|
| @@ -6829,6 +6858,8 @@ xmlParseConditionalSections(xmlParserCtxtPtr ctxt) {
|
| SKIP_BLANKS;
|
| if (RAW != '[') {
|
| xmlFatalErr(ctxt, XML_ERR_CONDSEC_INVALID, NULL);
|
| + xmlHaltParser(ctxt);
|
| + return;
|
| } else {
|
| if (ctxt->input->id != id) {
|
| xmlValidityError(ctxt, XML_ERR_ENTITY_BOUNDARY,
|
| @@ -6884,6 +6915,8 @@ xmlParseConditionalSections(xmlParserCtxtPtr ctxt) {
|
|
|
| } else {
|
| xmlFatalErr(ctxt, XML_ERR_CONDSEC_INVALID_KEYWORD, NULL);
|
| + xmlHaltParser(ctxt);
|
| + return;
|
| }
|
|
|
| if (RAW == 0)
|
| @@ -6897,7 +6930,9 @@ xmlParseConditionalSections(xmlParserCtxtPtr ctxt) {
|
| "All markup of the conditional section is not in the same entity\n",
|
| NULL, NULL);
|
| }
|
| - SKIP(3);
|
| + if ((ctxt-> instate != XML_PARSER_EOF) &&
|
| + ((ctxt->input->cur + 3) <= ctxt->input->end))
|
| + SKIP(3);
|
| }
|
| }
|
|
|
| @@ -6952,6 +6987,14 @@ xmlParseMarkupDecl(xmlParserCtxtPtr ctxt) {
|
| xmlParsePI(ctxt);
|
| }
|
| }
|
| +
|
| + /*
|
| + * detect requirement to exit there and act accordingly
|
| + * and avoid having instate overriden later on
|
| + */
|
| + if (ctxt->instate == XML_PARSER_EOF)
|
| + return;
|
| +
|
| /*
|
| * This is only for internal subset. On external entities,
|
| * the replacement is done before parsing stage
|
| @@ -7083,7 +7126,7 @@ xmlParseExternalSubset(xmlParserCtxtPtr ctxt, const xmlChar *ExternalID,
|
| /*
|
| * The XML REC instructs us to stop parsing right here
|
| */
|
| - ctxt->instate = XML_PARSER_EOF;
|
| + xmlHaltParser(ctxt);
|
| return;
|
| }
|
| }
|
| @@ -7235,7 +7278,8 @@ xmlParseReference(xmlParserCtxtPtr ctxt) {
|
| * far more secure as the parser will only process data coming from
|
| * the document entity by default.
|
| */
|
| - if ((ent->checked == 0) &&
|
| + if (((ent->checked == 0) ||
|
| + ((ent->children == NULL) && (ctxt->options & XML_PARSE_NOENT))) &&
|
| ((ent->etype != XML_EXTERNAL_GENERAL_PARSED_ENTITY) ||
|
| (ctxt->options & (XML_PARSE_NOENT | XML_PARSE_DTDVALID)))) {
|
| unsigned long oldnbent = ctxt->nbentities;
|
| @@ -8069,7 +8113,7 @@ xmlParsePEReference(xmlParserCtxtPtr ctxt)
|
| * The XML REC instructs us to stop parsing
|
| * right here
|
| */
|
| - ctxt->instate = XML_PARSER_EOF;
|
| + xmlHaltParser(ctxt);
|
| return;
|
| }
|
| }
|
| @@ -8424,6 +8468,7 @@ xmlParseInternalSubset(xmlParserCtxtPtr ctxt) {
|
| */
|
| if (RAW != '>') {
|
| xmlFatalErr(ctxt, XML_ERR_DOCTYPE_NOT_FINISHED, NULL);
|
| + return;
|
| }
|
| NEXT;
|
| }
|
| @@ -9304,7 +9349,7 @@ xmlParseStartTag2(xmlParserCtxtPtr ctxt, const xmlChar **pref,
|
| const xmlChar **atts = ctxt->atts;
|
| int maxatts = ctxt->maxatts;
|
| int nratts, nbatts, nbdef;
|
| - int i, j, nbNs, attval, oldline, oldcol;
|
| + int i, j, nbNs, attval, oldline, oldcol, inputNr;
|
| const xmlChar *base;
|
| unsigned long cur;
|
| int nsNr = ctxt->nsNr;
|
| @@ -9323,6 +9368,7 @@ reparse:
|
| SHRINK;
|
| base = ctxt->input->base;
|
| cur = ctxt->input->cur - ctxt->input->base;
|
| + inputNr = ctxt->inputNr;
|
| oldline = ctxt->input->line;
|
| oldcol = ctxt->input->col;
|
| nbatts = 0;
|
| @@ -9348,7 +9394,8 @@ reparse:
|
| */
|
| SKIP_BLANKS;
|
| GROW;
|
| - if (ctxt->input->base != base) goto base_changed;
|
| + if ((ctxt->input->base != base) || (inputNr != ctxt->inputNr))
|
| + goto base_changed;
|
|
|
| while (((RAW != '>') &&
|
| ((RAW != '/') || (NXT(1) != '>')) &&
|
| @@ -9359,7 +9406,7 @@ reparse:
|
|
|
| attname = xmlParseAttribute2(ctxt, prefix, localname,
|
| &aprefix, &attvalue, &len, &alloc);
|
| - if (ctxt->input->base != base) {
|
| + if ((ctxt->input->base != base) || (inputNr != ctxt->inputNr)) {
|
| if ((attvalue != NULL) && (alloc != 0))
|
| xmlFree(attvalue);
|
| attvalue = NULL;
|
| @@ -9508,7 +9555,8 @@ skip_ns:
|
| break;
|
| }
|
| SKIP_BLANKS;
|
| - if (ctxt->input->base != base) goto base_changed;
|
| + if ((ctxt->input->base != base) || (inputNr != ctxt->inputNr))
|
| + goto base_changed;
|
| continue;
|
| }
|
|
|
| @@ -9545,7 +9593,8 @@ failed:
|
| GROW
|
| if (ctxt->instate == XML_PARSER_EOF)
|
| break;
|
| - if (ctxt->input->base != base) goto base_changed;
|
| + if ((ctxt->input->base != base) || (inputNr != ctxt->inputNr))
|
| + goto base_changed;
|
| if ((RAW == '>') || (((RAW == '/') && (NXT(1) == '>'))))
|
| break;
|
| if (!IS_BLANK_CH(RAW)) {
|
| @@ -9561,7 +9610,8 @@ failed:
|
| break;
|
| }
|
| GROW;
|
| - if (ctxt->input->base != base) goto base_changed;
|
| + if ((ctxt->input->base != base) || (inputNr != ctxt->inputNr))
|
| + goto base_changed;
|
| }
|
|
|
| /*
|
| @@ -9728,6 +9778,17 @@ base_changed:
|
| if ((ctxt->attallocs[j] != 0) && (atts[i] != NULL))
|
| xmlFree((xmlChar *) atts[i]);
|
| }
|
| +
|
| + /*
|
| + * We can't switch from one entity to another in the middle
|
| + * of a start tag
|
| + */
|
| + if (inputNr != ctxt->inputNr) {
|
| + xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
|
| + "Start tag doesn't start and stop in the same entity\n");
|
| + return(NULL);
|
| + }
|
| +
|
| ctxt->input->cur = ctxt->input->base + cur;
|
| ctxt->input->line = oldline;
|
| ctxt->input->col = oldcol;
|
| @@ -10009,7 +10070,7 @@ xmlParseContent(xmlParserCtxtPtr ctxt) {
|
| if ((cons == ctxt->input->consumed) && (test == CUR_PTR)) {
|
| xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR,
|
| "detected an error in element content\n");
|
| - ctxt->instate = XML_PARSER_EOF;
|
| + xmlHaltParser(ctxt);
|
| break;
|
| }
|
| }
|
| @@ -10044,7 +10105,7 @@ xmlParseElement(xmlParserCtxtPtr ctxt) {
|
| xmlFatalErrMsgInt(ctxt, XML_ERR_INTERNAL_ERROR,
|
| "Excessive depth in document: %d use XML_PARSE_HUGE option\n",
|
| xmlParserMaxDepth);
|
| - ctxt->instate = XML_PARSER_EOF;
|
| + xmlHaltParser(ctxt);
|
| return;
|
| }
|
|
|
| @@ -10396,6 +10457,8 @@ xmlParseEncodingDecl(xmlParserCtxtPtr ctxt) {
|
| encoding = xmlParseEncName(ctxt);
|
| if (RAW != '"') {
|
| xmlFatalErr(ctxt, XML_ERR_STRING_NOT_CLOSED, NULL);
|
| + xmlFree((xmlChar *) encoding);
|
| + return(NULL);
|
| } else
|
| NEXT;
|
| } else if (RAW == '\''){
|
| @@ -10403,6 +10466,8 @@ xmlParseEncodingDecl(xmlParserCtxtPtr ctxt) {
|
| encoding = xmlParseEncName(ctxt);
|
| if (RAW != '\'') {
|
| xmlFatalErr(ctxt, XML_ERR_STRING_NOT_CLOSED, NULL);
|
| + xmlFree((xmlChar *) encoding);
|
| + return(NULL);
|
| } else
|
| NEXT;
|
| } else {
|
| @@ -10459,7 +10524,11 @@ xmlParseEncodingDecl(xmlParserCtxtPtr ctxt) {
|
|
|
| handler = xmlFindCharEncodingHandler((const char *) encoding);
|
| if (handler != NULL) {
|
| - xmlSwitchToEncoding(ctxt, handler);
|
| + if (xmlSwitchToEncoding(ctxt, handler) < 0) {
|
| + /* failed to convert */
|
| + ctxt->errNo = XML_ERR_UNSUPPORTED_ENCODING;
|
| + return(NULL);
|
| + }
|
| } else {
|
| xmlFatalErrMsgStr(ctxt, XML_ERR_UNSUPPORTED_ENCODING,
|
| "Unsupported encoding %s\n", encoding);
|
| @@ -10628,7 +10697,8 @@ xmlParseXMLDecl(xmlParserCtxtPtr ctxt) {
|
| xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED, "Blank needed here\n");
|
| }
|
| xmlParseEncodingDecl(ctxt);
|
| - if (ctxt->errNo == XML_ERR_UNSUPPORTED_ENCODING) {
|
| + if ((ctxt->errNo == XML_ERR_UNSUPPORTED_ENCODING) ||
|
| + (ctxt->instate == XML_PARSER_EOF)) {
|
| /*
|
| * The XML REC instructs us to stop parsing right here
|
| */
|
| @@ -10752,6 +10822,7 @@ xmlParseDocument(xmlParserCtxtPtr ctxt) {
|
|
|
| if (CUR == 0) {
|
| xmlFatalErr(ctxt, XML_ERR_DOCUMENT_EMPTY, NULL);
|
| + return(-1);
|
| }
|
|
|
| /*
|
| @@ -10769,7 +10840,8 @@ xmlParseDocument(xmlParserCtxtPtr ctxt) {
|
| * Note that we will switch encoding on the fly.
|
| */
|
| xmlParseXMLDecl(ctxt);
|
| - if (ctxt->errNo == XML_ERR_UNSUPPORTED_ENCODING) {
|
| + if ((ctxt->errNo == XML_ERR_UNSUPPORTED_ENCODING) ||
|
| + (ctxt->instate == XML_PARSER_EOF)) {
|
| /*
|
| * The XML REC instructs us to stop parsing right here
|
| */
|
| @@ -11165,7 +11237,7 @@ xmlCheckCdataPush(const xmlChar *utf, int len) {
|
| else
|
| return(-ix);
|
| } else if ((c & 0xe0) == 0xc0) {/* 2-byte code, starts with 110 */
|
| - if (ix + 2 > len) return(ix);
|
| + if (ix + 2 > len) return(-ix);
|
| if ((utf[ix+1] & 0xc0 ) != 0x80)
|
| return(-ix);
|
| codepoint = (utf[ix] & 0x1f) << 6;
|
| @@ -11174,7 +11246,7 @@ xmlCheckCdataPush(const xmlChar *utf, int len) {
|
| return(-ix);
|
| ix += 2;
|
| } else if ((c & 0xf0) == 0xe0) {/* 3-byte code, starts with 1110 */
|
| - if (ix + 3 > len) return(ix);
|
| + if (ix + 3 > len) return(-ix);
|
| if (((utf[ix+1] & 0xc0) != 0x80) ||
|
| ((utf[ix+2] & 0xc0) != 0x80))
|
| return(-ix);
|
| @@ -11185,7 +11257,7 @@ xmlCheckCdataPush(const xmlChar *utf, int len) {
|
| return(-ix);
|
| ix += 3;
|
| } else if ((c & 0xf8) == 0xf0) {/* 4-byte code, starts with 11110 */
|
| - if (ix + 4 > len) return(ix);
|
| + if (ix + 4 > len) return(-ix);
|
| if (((utf[ix+1] & 0xc0) != 0x80) ||
|
| ((utf[ix+2] & 0xc0) != 0x80) ||
|
| ((utf[ix+3] & 0xc0) != 0x80))
|
| @@ -11363,7 +11435,7 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
|
| ctxt->sax->setDocumentLocator(ctxt->userData,
|
| &xmlDefaultSAXLocator);
|
| xmlFatalErr(ctxt, XML_ERR_DOCUMENT_EMPTY, NULL);
|
| - ctxt->instate = XML_PARSER_EOF;
|
| + xmlHaltParser(ctxt);
|
| #ifdef DEBUG_PUSH
|
| xmlGenericError(xmlGenericErrorContext,
|
| "PP: entering EOF\n");
|
| @@ -11396,7 +11468,7 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
|
| * The XML REC instructs us to stop parsing right
|
| * here
|
| */
|
| - ctxt->instate = XML_PARSER_EOF;
|
| + xmlHaltParser(ctxt);
|
| return(0);
|
| }
|
| ctxt->standalone = ctxt->input->standalone;
|
| @@ -11452,7 +11524,7 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
|
| cur = ctxt->input->cur[0];
|
| if (cur != '<') {
|
| xmlFatalErr(ctxt, XML_ERR_DOCUMENT_EMPTY, NULL);
|
| - ctxt->instate = XML_PARSER_EOF;
|
| + xmlHaltParser(ctxt);
|
| if ((ctxt->sax) && (ctxt->sax->endDocument != NULL))
|
| ctxt->sax->endDocument(ctxt->userData);
|
| goto done;
|
| @@ -11484,7 +11556,7 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
|
| goto done;
|
| if (name == NULL) {
|
| spacePop(ctxt);
|
| - ctxt->instate = XML_PARSER_EOF;
|
| + xmlHaltParser(ctxt);
|
| if ((ctxt->sax) && (ctxt->sax->endDocument != NULL))
|
| ctxt->sax->endDocument(ctxt->userData);
|
| goto done;
|
| @@ -11651,7 +11723,7 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
|
| if ((cons == ctxt->input->consumed) && (test == CUR_PTR)) {
|
| xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR,
|
| "detected an error in element content\n");
|
| - ctxt->instate = XML_PARSER_EOF;
|
| + xmlHaltParser(ctxt);
|
| break;
|
| }
|
| break;
|
| @@ -11972,7 +12044,7 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
|
| goto done;
|
| } else {
|
| xmlFatalErr(ctxt, XML_ERR_DOCUMENT_END, NULL);
|
| - ctxt->instate = XML_PARSER_EOF;
|
| + xmlHaltParser(ctxt);
|
| #ifdef DEBUG_PUSH
|
| xmlGenericError(xmlGenericErrorContext,
|
| "PP: entering EOF\n");
|
| @@ -12336,7 +12408,7 @@ xmldecl_done:
|
| res = xmlParserInputBufferPush(ctxt->input->buf, size, chunk);
|
| if (res < 0) {
|
| ctxt->errNo = XML_PARSER_EOF;
|
| - ctxt->disableSAX = 1;
|
| + xmlHaltParser(ctxt);
|
| return (XML_PARSER_EOF);
|
| }
|
| xmlBufSetInputBaseCur(ctxt->input->buf->buffer, ctxt->input, base, cur);
|
| @@ -12390,7 +12462,7 @@ xmldecl_done:
|
| ((ctxt->input->cur - ctxt->input->base) > XML_MAX_LOOKUP_LIMIT)) &&
|
| ((ctxt->options & XML_PARSE_HUGE) == 0)) {
|
| xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR, "Huge input lookup");
|
| - ctxt->instate = XML_PARSER_EOF;
|
| + xmlHaltParser(ctxt);
|
| }
|
| if ((ctxt->errNo != XML_ERR_OK) && (ctxt->disableSAX == 1))
|
| return(ctxt->errNo);
|
| @@ -12578,25 +12650,47 @@ xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax, void *user_data,
|
| #endif /* LIBXML_PUSH_ENABLED */
|
|
|
| /**
|
| - * xmlStopParser:
|
| + * xmlHaltParser:
|
| * @ctxt: an XML parser context
|
| *
|
| - * Blocks further parser processing
|
| + * Blocks further parser processing don't override error
|
| + * for internal use
|
| */
|
| -void
|
| -xmlStopParser(xmlParserCtxtPtr ctxt) {
|
| +static void
|
| +xmlHaltParser(xmlParserCtxtPtr ctxt) {
|
| if (ctxt == NULL)
|
| return;
|
| ctxt->instate = XML_PARSER_EOF;
|
| - ctxt->errNo = XML_ERR_USER_STOP;
|
| ctxt->disableSAX = 1;
|
| if (ctxt->input != NULL) {
|
| + /*
|
| + * in case there was a specific allocation deallocate before
|
| + * overriding base
|
| + */
|
| + if (ctxt->input->free != NULL) {
|
| + ctxt->input->free((xmlChar *) ctxt->input->base);
|
| + ctxt->input->free = NULL;
|
| + }
|
| ctxt->input->cur = BAD_CAST"";
|
| ctxt->input->base = ctxt->input->cur;
|
| }
|
| }
|
|
|
| /**
|
| + * xmlStopParser:
|
| + * @ctxt: an XML parser context
|
| + *
|
| + * Blocks further parser processing
|
| + */
|
| +void
|
| +xmlStopParser(xmlParserCtxtPtr ctxt) {
|
| + if (ctxt == NULL)
|
| + return;
|
| + xmlHaltParser(ctxt);
|
| + ctxt->errNo = XML_ERR_USER_STOP;
|
| +}
|
| +
|
| +/**
|
| * xmlCreateIOParserCtxt:
|
| * @sax: a SAX handler
|
| * @user_data: The user data returned on SAX callbacks
|
| @@ -13340,7 +13434,7 @@ xmlParseExternalEntityPrivate(xmlDocPtr doc, xmlParserCtxtPtr oldctxt,
|
| /*
|
| * Also record the size of the entity parsed
|
| */
|
| - if (ctxt->input != NULL) {
|
| + if (ctxt->input != NULL && oldctxt != NULL) {
|
| oldctxt->sizeentities += ctxt->input->consumed;
|
| oldctxt->sizeentities += (ctxt->input->cur - ctxt->input->base);
|
| }
|
| @@ -13352,9 +13446,11 @@ xmlParseExternalEntityPrivate(xmlDocPtr doc, xmlParserCtxtPtr oldctxt,
|
|
|
| if (sax != NULL)
|
| ctxt->sax = oldsax;
|
| - oldctxt->node_seq.maximum = ctxt->node_seq.maximum;
|
| - oldctxt->node_seq.length = ctxt->node_seq.length;
|
| - oldctxt->node_seq.buffer = ctxt->node_seq.buffer;
|
| + if (oldctxt != NULL) {
|
| + oldctxt->node_seq.maximum = ctxt->node_seq.maximum;
|
| + oldctxt->node_seq.length = ctxt->node_seq.length;
|
| + oldctxt->node_seq.buffer = ctxt->node_seq.buffer;
|
| + }
|
| ctxt->node_seq.maximum = 0;
|
| ctxt->node_seq.length = 0;
|
| ctxt->node_seq.buffer = NULL;
|
| @@ -14830,9 +14926,6 @@ xmlInitParser(void) {
|
| #ifdef LIBXML_XPATH_ENABLED
|
| xmlXPathInit();
|
| #endif
|
| -#ifdef LIBXML_CATALOG_ENABLED
|
| - xmlInitializeCatalog();
|
| -#endif
|
| xmlParserInitialized = 1;
|
| #ifdef LIBXML_THREAD_ENABLED
|
| }
|
|
|