Skip to contentSkip to conversation

libxml2: Fix CVE-2019-19956

PATCH Superseded [email protected] 2 participants 3 messages Jan 23, 2020

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libxml2: Fix CVE-2019-19956

From: Lee Chee Yang <[email protected]>

see:
https://gitlab.gnome.org/GNOME/libxml2/commit/5a02583c7e683896d84878bd90641d8d9b0d0549

---
 .../libxml/libxml2/Fix-CVE-2019-19956.patch        | 40 ++++++++++++++++++++++
 meta/recipes-core/libxml/libxml2_2.9.9.bb          |  1 +
 2 files changed, 41 insertions(+)
 create mode 100644 meta/recipes-core/libxml/libxml2/Fix-CVE-2019-19956.patch
meta/recipes-core/libxml/libxml2/Fix-CVE-2019-19956.patch new file +40 -0
new file mode 100644
index 0000000..1c2dff9
@@ -0,0 +1,40 @@
+From 5a02583c7e683896d84878bd90641d8d9b0d0549 Mon Sep 17 00:00:00 2001
+From: Zhipeng Xie <[email protected]>
+Date: Wed, 7 Aug 2019 17:39:17 +0800
+Subject: [PATCH] Fix memory leak in xmlParseBalancedChunkMemoryRecover
+
+When doc is NULL, namespace created in xmlTreeEnsureXMLDecl
+is bind to newDoc->oldNs, in this case, set newDoc->oldNs to
+NULL and free newDoc will cause a memory leak.
+
+Found with libFuzzer.
+
+Closes #82.
+
+Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/libxml2/commit/5a02583c7e683896d84878bd90641d8d9b0d0549]
+CVE: CVE-2019-19956
+
+Signed-off-by: Chee Yang Lee <[email protected]>
+
+---
+ parser.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/parser.c b/parser.c
+index 1ce1ccf1..26d9f4e3 100644
+--- a/parser.c
++++ b/parser.c
+@@ -13894,7 +13894,8 @@ xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc, xmlSAXHandlerPtr sax,
+     xmlFreeParserCtxt(ctxt);
+     newDoc->intSubset = NULL;
+     newDoc->extSubset = NULL;
+-    newDoc->oldNs = NULL;
++    if(doc != NULL)
++	newDoc->oldNs = NULL;
+     xmlFreeDoc(newDoc);
+ 
+     return(ret);
+-- 
+2.24.1
+
+
meta/recipes-core/libxml/libxml2_2.9.9.bb +1 -0
index c38f883..c44a90b 100644
@@ -20,6 +20,7 @@ SRC_URI = "http://www.xmlsoft.org/sources/libxml2-${PV}.tar.gz;name=libtar \
            file://libxml-m4-use-pkgconfig.patch \
            file://0001-Make-ptest-run-the-python-tests-if-python-is-enabled.patch \
            file://fix-execution-of-ptests.patch \
+           file://Fix-CVE-2019-19956.patch \
            "
 
 SRC_URI[libtar.md5sum] = "c04a5a0a042eaa157e8e8c9eabe76bd6"
Signature · 1 line
2.7.4
#1 lore raw
Quoted 6 lines · On 1/22/20 6:09 PM, [email protected] wrote:

From: Lee Chee Yang <[email protected]>

see:
https://gitlab.gnome.org/GNOME/libxml2/commit/5a02583c7e683896d84878bd90641d8d9b0d0549

So Master is not affected? 2.9.10

- armin

Quoted 64 lines
---
 .../libxml/libxml2/Fix-CVE-2019-19956.patch        | 40 ++++++++++++++++++++++
 meta/recipes-core/libxml/libxml2_2.9.9.bb          |  1 +
 2 files changed, 41 insertions(+)
 create mode 100644 meta/recipes-core/libxml/libxml2/Fix-CVE-2019-19956.patch
meta/recipes-core/libxml/libxml2/Fix-CVE-2019-19956.patch new file +40 -0
new file mode 100644
index 0000000..1c2dff9
@@ -0,0 +1,40 @@
+From 5a02583c7e683896d84878bd90641d8d9b0d0549 Mon Sep 17 00:00:00 2001
+From: Zhipeng Xie <[email protected]>
+Date: Wed, 7 Aug 2019 17:39:17 +0800
+Subject: [PATCH] Fix memory leak in xmlParseBalancedChunkMemoryRecover
+
+When doc is NULL, namespace created in xmlTreeEnsureXMLDecl
+is bind to newDoc->oldNs, in this case, set newDoc->oldNs to
+NULL and free newDoc will cause a memory leak.
+
+Found with libFuzzer.
+
+Closes #82.
+
+Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/libxml2/commit/5a02583c7e683896d84878bd90641d8d9b0d0549]
+CVE: CVE-2019-19956
+
+Signed-off-by: Chee Yang Lee <[email protected]>
+
+---
+ parser.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/parser.c b/parser.c
+index 1ce1ccf1..26d9f4e3 100644
+--- a/parser.c
++++ b/parser.c
+@@ -13894,7 +13894,8 @@ xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc, xmlSAXHandlerPtr sax,
+     xmlFreeParserCtxt(ctxt);
+     newDoc->intSubset = NULL;
+     newDoc->extSubset = NULL;
+-    newDoc->oldNs = NULL;
++    if(doc != NULL)
++	newDoc->oldNs = NULL;
+     xmlFreeDoc(newDoc);
+ 
+     return(ret);
+-- 
+2.24.1
+
+
meta/recipes-core/libxml/libxml2_2.9.9.bb +1 -0
index c38f883..c44a90b 100644
@@ -20,6 +20,7 @@ SRC_URI = "http://www.xmlsoft.org/sources/libxml2-${PV}.tar.gz;name=libtar \
            file://libxml-m4-use-pkgconfig.patch \
            file://0001-Make-ptest-run-the-python-tests-if-python-is-enabled.patch \
            file://fix-execution-of-ptests.patch \
+           file://Fix-CVE-2019-19956.patch \
            "
 
 SRC_URI[libtar.md5sum] = "c04a5a0a042eaa157e8e8c9eabe76bd6"
#2 lore raw

Yes, patch already in 2.9.10

-----Original Message-----
From: akuster808 <[email protected]>
Sent: Thursday, January 23, 2020 1:46 PM
To: Lee, Chee Yang <[email protected]>; [email protected]
Subject: Re: [OE-core] [PATCH][zeus] libxml2: Fix CVE-2019-19956

Quoted 7 lines · On 1/22/20 6:09 PM, [email protected] wrote:

From: Lee Chee Yang <[email protected]>

see:
https://gitlab.gnome.org/GNOME/libxml2/commit/5a02583c7e683896d84878bd
90641d8d9b0d0549

So Master is not affected? 2.9.10

- armin

Quoted 71 lines
---
 .../libxml/libxml2/Fix-CVE-2019-19956.patch        | 40 ++++++++++++++++++++++
 meta/recipes-core/libxml/libxml2_2.9.9.bb          |  1 +
 2 files changed, 41 insertions(+)
 create mode 100644 

meta/recipes-core/libxml/libxml2/Fix-CVE-2019-19956.patch

meta/recipes-core/libxml/libxml2/Fix-CVE-2019-19956.patch new file +44 -0
new file mode 100644
index 0000000..1c2dff9
@@ -0,0 +1,40 @@
+From 5a02583c7e683896d84878bd90641d8d9b0d0549 Mon Sep 17 00:00:00 
+2001
+From: Zhipeng Xie <[email protected]>
+Date: Wed, 7 Aug 2019 17:39:17 +0800
+Subject: [PATCH] Fix memory leak in 
+xmlParseBalancedChunkMemoryRecover
+
+When doc is NULL, namespace created in xmlTreeEnsureXMLDecl is bind 
+to newDoc->oldNs, in this case, set newDoc->oldNs to NULL and free 
+newDoc will cause a memory leak.
+
+Found with libFuzzer.
+
+Closes #82.
+
+Upstream-Status: Backport 
+[https://gitlab.gnome.org/GNOME/libxml2/commit/5a02583c7e683896d84878
+bd90641d8d9b0d0549]
+CVE: CVE-2019-19956
+
+Signed-off-by: Chee Yang Lee <[email protected]>
+
+---
+ parser.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/parser.c b/parser.c
+index 1ce1ccf1..26d9f4e3 100644
+--- a/parser.c
++++ b/parser.c
+@@ -13894,7 +13894,8 @@ xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc, xmlSAXHandlerPtr sax,
+     xmlFreeParserCtxt(ctxt);
+     newDoc->intSubset = NULL;
+     newDoc->extSubset = NULL;
+-    newDoc->oldNs = NULL;
++    if(doc != NULL)
++	newDoc->oldNs = NULL;
+     xmlFreeDoc(newDoc);
+ 
+     return(ret);
+--
+2.24.1
+
+
meta/recipes-core/libxml/libxml2_2.9.9.bb +1 -0
index c38f883..c44a90b 100644
@@ -20,6 +20,7 @@ SRC_URI = "http://www.xmlsoft.org/sources/libxml2-${PV}.tar.gz;name=libtar \
            file://libxml-m4-use-pkgconfig.patch \
            file://0001-Make-ptest-run-the-python-tests-if-python-is-enabled.patch \
            file://fix-execution-of-ptests.patch \
+           file://Fix-CVE-2019-19956.patch \
            "
 
 SRC_URI[libtar.md5sum] = "c04a5a0a042eaa157e8e8c9eabe76bd6"