!23 回退补丁 Don-t-try-to-handle-namespaces-when-building-HTML-do.patch

From: @yang_zhuang_zhuang
Reviewed-by: @xiezhipeng1
Signed-off-by: @xiezhipeng1
This commit is contained in:
openeuler-ci-bot 2020-09-14 17:12:19 +08:00 committed by Gitee
commit 6ee10271f0
2 changed files with 16 additions and 128 deletions

View File

@ -1,115 +0,0 @@
From 21ca8829a7366d72995adfeb21296d959fbb3777 Mon Sep 17 00:00:00 2001
From: Nick Wellnhofer <wellnhofer@aevum.de>
Date: Sat, 25 Jul 2020 17:57:29 +0200
Subject: [PATCH 095/139] Don't try to handle namespaces when building HTML
documents
Don't try to resolve namespace in xmlSAX2StartElement when parsing
HTML documents. This useless operation could slow down the parser
considerably.
Found by OSS-Fuzz.
---
SAX2.c | 76 +++++++++++++++++++++++++++++++++---------------------------------
1 file changed, 38 insertions(+), 38 deletions(-)
diff --git a/SAX2.c b/SAX2.c
index 9df0184..4450a3f 100644
--- a/SAX2.c
+++ b/SAX2.c
@@ -1663,23 +1663,23 @@ xmlSAX2StartElement(void *ctx, const xmlChar *fullname, const xmlChar **atts)
}
}
- /*
- * Insert all the defaulted attributes from the DTD especially namespaces
- */
- if ((!ctxt->html) &&
- ((ctxt->myDoc->intSubset != NULL) ||
- (ctxt->myDoc->extSubset != NULL))) {
- xmlCheckDefaultedAttributes(ctxt, name, prefix, atts);
- }
+ if (!ctxt->html) {
+ /*
+ * Insert all the defaulted attributes from the DTD especially
+ * namespaces
+ */
+ if ((ctxt->myDoc->intSubset != NULL) ||
+ (ctxt->myDoc->extSubset != NULL)) {
+ xmlCheckDefaultedAttributes(ctxt, name, prefix, atts);
+ }
- /*
- * process all the attributes whose name start with "xmlns"
- */
- if (atts != NULL) {
- i = 0;
- att = atts[i++];
- value = atts[i++];
- if (!ctxt->html) {
+ /*
+ * process all the attributes whose name start with "xmlns"
+ */
+ if (atts != NULL) {
+ i = 0;
+ att = atts[i++];
+ value = atts[i++];
while ((att != NULL) && (value != NULL)) {
if ((att[0] == 'x') && (att[1] == 'm') && (att[2] == 'l') &&
(att[3] == 'n') && (att[4] == 's'))
@@ -1688,30 +1688,30 @@ xmlSAX2StartElement(void *ctx, const xmlChar *fullname, const xmlChar **atts)
att = atts[i++];
value = atts[i++];
}
- }
- }
+ }
- /*
- * Search the namespace, note that since the attributes have been
- * processed, the local namespaces are available.
- */
- ns = xmlSearchNs(ctxt->myDoc, ret, prefix);
- if ((ns == NULL) && (parent != NULL))
- ns = xmlSearchNs(ctxt->myDoc, parent, prefix);
- if ((prefix != NULL) && (ns == NULL)) {
- ns = xmlNewNs(ret, NULL, prefix);
- xmlNsWarnMsg(ctxt, XML_NS_ERR_UNDEFINED_NAMESPACE,
- "Namespace prefix %s is not defined\n",
- prefix, NULL);
- }
+ /*
+ * Search the namespace, note that since the attributes have been
+ * processed, the local namespaces are available.
+ */
+ ns = xmlSearchNs(ctxt->myDoc, ret, prefix);
+ if ((ns == NULL) && (parent != NULL))
+ ns = xmlSearchNs(ctxt->myDoc, parent, prefix);
+ if ((prefix != NULL) && (ns == NULL)) {
+ ns = xmlNewNs(ret, NULL, prefix);
+ xmlNsWarnMsg(ctxt, XML_NS_ERR_UNDEFINED_NAMESPACE,
+ "Namespace prefix %s is not defined\n",
+ prefix, NULL);
+ }
- /*
- * set the namespace node, making sure that if the default namespace
- * is unbound on a parent we simply keep it NULL
- */
- if ((ns != NULL) && (ns->href != NULL) &&
- ((ns->href[0] != 0) || (ns->prefix != NULL)))
- xmlSetNs(ret, ns);
+ /*
+ * set the namespace node, making sure that if the default namespace
+ * is unbound on a parent we simply keep it NULL
+ */
+ if ((ns != NULL) && (ns->href != NULL) &&
+ ((ns->href[0] != 0) || (ns->prefix != NULL)))
+ xmlSetNs(ret, ns);
+ }
/*
* process all the other attributes
--
1.8.3.1

View File

@ -1,7 +1,7 @@
Summary: Library providing XML and HTML support
Name: libxml2
Version: 2.9.10
Release: 7
Release: 8
License: MIT
Group: Development/Libraries
Source: ftp://xmlsoft.org/libxml2/libxml2-%{version}.tar.gz
@ -42,18 +42,17 @@ Patch32: Fix-integer-overflow-when-parsing-min-max-Occurs.patch
Patch33: Fix-integer-overflow-in-_xmlSchemaParseGYear.patch
Patch34: Fix-quadratic-runtime-when-parsing-HTML-script-conte.patch
Patch35: Fix-UTF-8-decoder-in-HTML-parser.patch
Patch36: Don-t-try-to-handle-namespaces-when-building-HTML-do.patch
Patch37: Fix-integer-overflow-when-comparing-schema-dates.patch
Patch38: Fix-memory-leak-in-xmlXIncludeIncludeNode-error-path.patch
Patch39: Don-t-recurse-into-xi-include-children-in-xmlXInclud.patch
Patch40: Don-t-process-siblings-of-root-in-xmlXIncludeProcess.patch
Patch41: Fix-exponential-runtime-and-memory-in-xi-fallback-pr.patch
Patch42: Fuzz-XInclude-engine.patch
Patch43: Fix-memory-leak-in-runtest.c.patch
Patch44: Fix-XInclude-regression-introduced-with-recent-commi.patch
Patch45: Fix-memory-leak-in-xmlXIncludeAddNode-error-paths.patch
Patch46: Fix-double-free-in-XML-reader-with-XIncludes.patch
Patch47: Limit-size-of-free-lists-in-XML-reader-when-fuzzing.patch
Patch36: Fix-integer-overflow-when-comparing-schema-dates.patch
Patch37: Fix-memory-leak-in-xmlXIncludeIncludeNode-error-path.patch
Patch38: Don-t-recurse-into-xi-include-children-in-xmlXInclud.patch
Patch39: Don-t-process-siblings-of-root-in-xmlXIncludeProcess.patch
Patch40: Fix-exponential-runtime-and-memory-in-xi-fallback-pr.patch
Patch41: Fuzz-XInclude-engine.patch
Patch42: Fix-memory-leak-in-runtest.c.patch
Patch43: Fix-XInclude-regression-introduced-with-recent-commi.patch
Patch44: Fix-memory-leak-in-xmlXIncludeAddNode-error-paths.patch
Patch45: Fix-double-free-in-XML-reader-with-XIncludes.patch
Patch46: Limit-size-of-free-lists-in-XML-reader-when-fuzzing.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-root
BuildRequires: python2-devel
@ -245,6 +244,10 @@ rm -fr %{buildroot}
%changelog
* Mon Sep 14 2020 yangzhuangzhuang <yangzhuangzhuang1@huawei.com> - 2.9.10-8
- revert Don-t-try-to-handle-namespaces-when-building-HTML-do.patch.
rubygem-nokogoro test case fail,because this patch remove xml namespace function.
* Thu Sep 10 2020 yangzhuangzhuang <yangzhuangzhuang1@huawei.com> - 2.9.10-7
- Fixed some issues found in fuzzing testcases