From 8fcde53e278e8747434d9736968d74d5775aa83d Mon Sep 17 00:00:00 2001 From: Packit Service Date: Dec 09 2020 21:13:02 +0000 Subject: Prepare for a new update Reverting patches so we can apply the latest update and changes can be seen in the spec file and sources. --- diff --git a/entities.c b/entities.c index 59e72c7..c819337 100644 --- a/entities.c +++ b/entities.c @@ -164,7 +164,6 @@ xmlCreateEntity(xmlDictPtr dict, const xmlChar *name, int type, memset(ret, 0, sizeof(xmlEntity)); ret->type = XML_ENTITY_DECL; ret->checked = 0; - ret->guard = XML_ENTITY_NOT_BEING_CHECKED; /* * fill the structure. @@ -937,7 +936,6 @@ xmlCopyEntity(xmlEntityPtr ent) { cur->orig = xmlStrdup(ent->orig); if (ent->URI != NULL) cur->URI = xmlStrdup(ent->URI); - cur->guard = 0; return(cur); } diff --git a/include/libxml/entities.h b/include/libxml/entities.h index 52a6a97..47b4573 100644 --- a/include/libxml/entities.h +++ b/include/libxml/entities.h @@ -30,11 +30,6 @@ typedef enum { XML_INTERNAL_PREDEFINED_ENTITY = 6 } xmlEntityType; -typedef enum { - XML_ENTITY_NOT_BEING_CHECKED, - XML_ENTITY_BEING_CHECKED /* entity check is in progress */ -} xmlEntityRecursionGuard; - /* * An unit of storage for an entity, contains the string, the value * and the linkind data needed for the linking in the hash table. @@ -65,7 +60,6 @@ struct _xmlEntity { /* this is also used to count entities * references done from that entity * and if it contains '<' */ - xmlEntityRecursionGuard guard; }; /* diff --git a/parser.c b/parser.c index af1ec86..1c5e036 100644 --- a/parser.c +++ b/parser.c @@ -139,10 +139,6 @@ xmlParserEntityCheck(xmlParserCtxtPtr ctxt, size_t size, if (ctxt->lastError.code == XML_ERR_ENTITY_LOOP) return (1); - if ((ent != NULL) && (ent->guard == XML_ENTITY_BEING_CHECKED)) { - xmlFatalErr(ctxt, XML_ERR_ENTITY_LOOP, NULL); - return (1); - } /* * This may look absurd but is needed to detect * entities problems @@ -153,14 +149,12 @@ xmlParserEntityCheck(xmlParserCtxtPtr ctxt, size_t size, unsigned long oldnbent = ctxt->nbentities; xmlChar *rep; - ent->guard = XML_ENTITY_BEING_CHECKED; ent->checked = 1; ++ctxt->depth; rep = xmlStringDecodeEntities(ctxt, ent->content, XML_SUBSTITUTE_REF, 0, 0, 0); --ctxt->depth; - ent->guard = XML_ENTITY_NOT_BEING_CHECKED; if (ctxt->errNo == XML_ERR_ENTITY_LOOP) { ent->content[0] = 0; } @@ -2637,8 +2631,7 @@ xmlStringLenDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int len, else c = 0; while ((c != 0) && (c != end) && /* non input consuming loop */ - (c != end2) && (c != end3) && - (ctxt->instate != XML_PARSER_EOF)) { + (c != end2) && (c != end3)) { if (c == 0) break; if ((c == '&') && (str[1] == '#')) { @@ -7117,28 +7110,23 @@ xmlParseReference(xmlParserCtxtPtr ctxt) { * if its replacement text matches the production labeled * content. */ - if (ent->guard == XML_ENTITY_BEING_CHECKED) { - ret = XML_ERR_ENTITY_LOOP; - } else { - ent->guard = XML_ENTITY_BEING_CHECKED; - if (ent->etype == XML_INTERNAL_GENERAL_ENTITY) { - ctxt->depth++; - ret = xmlParseBalancedChunkMemoryInternal(ctxt, ent->content, - user_data, &list); - ctxt->depth--; - } else if (ent->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY) { - ctxt->depth++; - ret = xmlParseExternalEntityPrivate(ctxt->myDoc, ctxt, ctxt->sax, - user_data, ctxt->depth, ent->URI, - ent->ExternalID, &list); - ctxt->depth--; - } else { - ret = XML_ERR_ENTITY_PE_INTERNAL; - xmlErrMsgStr(ctxt, XML_ERR_INTERNAL_ERROR, - "invalid entity type found\n", NULL); - } - ent->guard = XML_ENTITY_NOT_BEING_CHECKED; - } + if (ent->etype == XML_INTERNAL_GENERAL_ENTITY) { + ctxt->depth++; + ret = xmlParseBalancedChunkMemoryInternal(ctxt, ent->content, + user_data, &list); + ctxt->depth--; + + } else if (ent->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY) { + ctxt->depth++; + ret = xmlParseExternalEntityPrivate(ctxt->myDoc, ctxt, ctxt->sax, + user_data, ctxt->depth, ent->URI, + ent->ExternalID, &list); + ctxt->depth--; + } else { + ret = XML_ERR_ENTITY_PE_INTERNAL; + xmlErrMsgStr(ctxt, XML_ERR_INTERNAL_ERROR, + "invalid entity type found\n", NULL); + } /* * Store the number of entities needing parsing for this entity @@ -7244,29 +7232,23 @@ xmlParseReference(xmlParserCtxtPtr ctxt) { else user_data = ctxt->userData; - if (ent->guard == XML_ENTITY_BEING_CHECKED) { - ret = XML_ERR_ENTITY_LOOP; - } else { - ent->guard = XML_ENTITY_BEING_CHECKED; - if (ent->etype == XML_INTERNAL_GENERAL_ENTITY) { - ctxt->depth++; - ret = xmlParseBalancedChunkMemoryInternal(ctxt, - ent->content, user_data, NULL); - ctxt->depth--; - } else if (ent->etype == - XML_EXTERNAL_GENERAL_PARSED_ENTITY) { - ctxt->depth++; - ret = xmlParseExternalEntityPrivate(ctxt->myDoc, ctxt, - ctxt->sax, user_data, ctxt->depth, - ent->URI, ent->ExternalID, NULL); - ctxt->depth--; - } else { - ret = XML_ERR_ENTITY_PE_INTERNAL; - xmlErrMsgStr(ctxt, XML_ERR_INTERNAL_ERROR, - "invalid entity type found\n", NULL); - } - ent->guard = XML_ENTITY_NOT_BEING_CHECKED; - } + if (ent->etype == XML_INTERNAL_GENERAL_ENTITY) { + ctxt->depth++; + ret = xmlParseBalancedChunkMemoryInternal(ctxt, + ent->content, user_data, NULL); + ctxt->depth--; + } else if (ent->etype == + XML_EXTERNAL_GENERAL_PARSED_ENTITY) { + ctxt->depth++; + ret = xmlParseExternalEntityPrivate(ctxt->myDoc, ctxt, + ctxt->sax, user_data, ctxt->depth, + ent->URI, ent->ExternalID, NULL); + ctxt->depth--; + } else { + ret = XML_ERR_ENTITY_PE_INTERNAL; + xmlErrMsgStr(ctxt, XML_ERR_INTERNAL_ERROR, + "invalid entity type found\n", NULL); + } if (ret == XML_ERR_ENTITY_LOOP) { xmlFatalErr(ctxt, XML_ERR_ENTITY_LOOP, NULL); return; @@ -13910,8 +13892,7 @@ xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc, xmlSAXHandlerPtr sax, xmlFreeParserCtxt(ctxt); newDoc->intSubset = NULL; newDoc->extSubset = NULL; - if(doc != NULL) - newDoc->oldNs = NULL; + newDoc->oldNs = NULL; xmlFreeDoc(newDoc); return(ret); diff --git a/python/libxml.c b/python/libxml.c index 8b659da..5b1ff6e 100644 --- a/python/libxml.c +++ b/python/libxml.c @@ -1620,7 +1620,6 @@ libxml_xmlErrorFuncHandler(ATTRIBUTE_UNUSED void *ctx, const char *msg, PyObject *message; PyObject *result; char str[1000]; - unsigned char *ptr = (unsigned char *)str; #ifdef DEBUG_ERROR printf("libxml_xmlErrorFuncHandler(%p, %s, ...) called\n", ctx, msg); @@ -1637,20 +1636,12 @@ libxml_xmlErrorFuncHandler(ATTRIBUTE_UNUSED void *ctx, const char *msg, str[999] = 0; va_end(ap); -#if PY_MAJOR_VERSION >= 3 - /* Ensure the error string doesn't start at UTF8 continuation. */ - while (*ptr && (*ptr & 0xc0) == 0x80) - ptr++; -#endif - list = PyTuple_New(2); PyTuple_SetItem(list, 0, libxml_xmlPythonErrorFuncCtxt); Py_XINCREF(libxml_xmlPythonErrorFuncCtxt); - message = libxml_charPtrConstWrap(ptr); + message = libxml_charPtrConstWrap(str); PyTuple_SetItem(list, 1, message); result = PyEval_CallObject(libxml_xmlPythonErrorFuncHandler, list); - /* Forget any errors caused in the error handler. */ - PyErr_Clear(); Py_XDECREF(list); Py_XDECREF(result); } diff --git a/python/types.c b/python/types.c index 124af56..f237677 100644 --- a/python/types.c +++ b/python/types.c @@ -31,6 +31,8 @@ libxml_PyFileGet(PyObject *f) { const char *mode; fd = PyObject_AsFileDescriptor(f); + if (!_PyVerify_fd(fd)) + return(NULL); /* * Get the flags on the fd to understand how it was opened */ diff --git a/xml2-config.in b/xml2-config.in index 5453ab2..1957486 100644 --- a/xml2-config.in +++ b/xml2-config.in @@ -3,12 +3,7 @@ prefix=@prefix@ exec_prefix=@exec_prefix@ includedir=@includedir@ -if [ "`ldd /bin/sh | grep lib64`" = "" ] -then - libdir=${exec_prefix}/lib -else - libdir=${exec_prefix}/lib64 -fi +libdir=@libdir@ usage() { diff --git a/xmlschemas.c b/xmlschemas.c index df26869..05a12e0 100644 --- a/xmlschemas.c +++ b/xmlschemas.c @@ -28080,6 +28080,7 @@ xmlSchemaPreRun(xmlSchemaValidCtxtPtr vctxt) { vctxt->nberrors = 0; vctxt->depth = -1; vctxt->skipDepth = -1; + vctxt->xsiAssemble = 0; vctxt->hasKeyrefs = 0; #ifdef ENABLE_IDC_NODE_TABLES_TEST vctxt->createIDCNodeTables = 1; diff --git a/xpath.c b/xpath.c index 3fcdc9e..3527473 100644 --- a/xpath.c +++ b/xpath.c @@ -13337,8 +13337,9 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op) return(0); } xmlXPathBooleanFunction(ctxt, 1); - if (ctxt->value != NULL) - ctxt->value->boolval &= arg2->boolval; + arg1 = valuePop(ctxt); + arg1->boolval &= arg2->boolval; + valuePush(ctxt, arg1); xmlXPathReleaseObject(ctxt->context, arg2); return (total); case XPATH_OP_OR: @@ -13362,8 +13363,9 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op) return(0); } xmlXPathBooleanFunction(ctxt, 1); - if (ctxt->value != NULL) - ctxt->value->boolval |= arg2->boolval; + arg1 = valuePop(ctxt); + arg1->boolval |= arg2->boolval; + valuePush(ctxt, arg1); xmlXPathReleaseObject(ctxt->context, arg2); return (total); case XPATH_OP_EQUAL: diff --git a/xzlib.c b/xzlib.c index 0f2ddc0..8bafbd3 100644 --- a/xzlib.c +++ b/xzlib.c @@ -562,10 +562,6 @@ xz_decomp(xz_statep state) "internal error: inflate stream corrupt"); return -1; } - /* - * FIXME: Remapping a couple of error codes and falling through - * to the LZMA error handling looks fragile. - */ if (ret == Z_MEM_ERROR) ret = LZMA_MEM_ERROR; if (ret == Z_DATA_ERROR) @@ -591,11 +587,6 @@ xz_decomp(xz_statep state) xz_error(state, LZMA_PROG_ERROR, "compression error"); return -1; } - if ((state->how != GZIP) && - (ret != LZMA_OK) && (ret != LZMA_STREAM_END)) { - xz_error(state, ret, "lzma error"); - return -1; - } } while (strm->avail_out && ret != LZMA_STREAM_END); /* update available output and crc check value */ @@ -610,20 +601,17 @@ xz_decomp(xz_statep state) #ifdef HAVE_ZLIB_H if (state->how == GZIP) { if (gz_next4(state, &crc) == -1 || gz_next4(state, &len) == -1) { - /* - xz_error(state, LZMA_DATA_ERROR, "unexpected end of file"); - return -1; - */ - } else { - if (crc != state->zstrm.adler) { - xz_error(state, LZMA_DATA_ERROR, "incorrect data check"); - return -1; - } - if (len != (state->zstrm.total_out & 0xffffffffL)) { - xz_error(state, LZMA_DATA_ERROR, "incorrect length check"); - return -1; - } - } + xz_error(state, LZMA_DATA_ERROR, "unexpected end of file"); + return -1; + } + if (crc != state->zstrm.adler) { + xz_error(state, LZMA_DATA_ERROR, "incorrect data check"); + return -1; + } + if (len != (state->zstrm.total_out & 0xffffffffL)) { + xz_error(state, LZMA_DATA_ERROR, "incorrect length check"); + return -1; + } state->strm.avail_in = 0; state->strm.next_in = NULL; state->strm.avail_out = 0;