commit
d76d981b64
@ -1,129 +0,0 @@
|
||||
From 477d91c30f0ba433a35e3d6bcf69ea5ef3f75a5f Mon Sep 17 00:00:00 2001
|
||||
From: lsh123 <aleksey@aleksey.com>
|
||||
Date: Mon, 2 Jul 2018 16:48:09 -0700
|
||||
Subject: [PATCH] fix xmlSecParseMemory() memory leak (issue #199) (#202)
|
||||
|
||||
---
|
||||
src/parser.c | 35 +++++++++++++++++++++++++++++++----
|
||||
src/xslt.c | 4 ++++
|
||||
2 files changed, 35 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/src/parser.c b/src/parser.c
|
||||
index e18b2d3..ddeb590 100644
|
||||
--- a/src/parser.c
|
||||
+++ b/src/parser.c
|
||||
@@ -132,6 +132,10 @@ xmlSecParserFinalize(xmlSecTransformPtr transform) {
|
||||
xmlSecAssert(ctx != NULL);
|
||||
|
||||
if(ctx->parserCtx != NULL) {
|
||||
+ if(ctx->parserCtx->myDoc != NULL) {
|
||||
+ xmlFreeDoc(ctx->parserCtx->myDoc);
|
||||
+ ctx->parserCtx->myDoc = NULL;
|
||||
+ }
|
||||
xmlFreeParserCtxt(ctx->parserCtx);
|
||||
}
|
||||
memset(ctx, 0, sizeof(xmlSecParserCtx));
|
||||
@@ -294,6 +298,10 @@ xmlSecParserPopXml(xmlSecTransformPtr transform, xmlSecNodeSetPtr* nodes,
|
||||
xmlSecXmlParserError("inputPush", ctxt,
|
||||
xmlSecTransformGetName(transform));
|
||||
xmlFreeInputStream(input);
|
||||
+ if(ctxt->myDoc != NULL) {
|
||||
+ xmlFreeDoc(ctxt->myDoc);
|
||||
+ ctxt->myDoc = NULL;
|
||||
+ }
|
||||
xmlFreeParserCtxt(ctxt);
|
||||
return(-1);
|
||||
}
|
||||
@@ -404,20 +412,27 @@ xmlSecParseFile(const char *filename) {
|
||||
xmlSecXmlParserError2("xmlParseDocument", ctxt, NULL,
|
||||
"filename=%s",
|
||||
xmlSecErrorsSafeString(filename));
|
||||
+ if(ctxt->myDoc != NULL) {
|
||||
+ xmlFreeDoc(ctxt->myDoc);
|
||||
+ ctxt->myDoc = NULL;
|
||||
+ }
|
||||
xmlFreeParserCtxt(ctxt);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
if(!ctxt->wellFormed) {
|
||||
xmlSecInternalError("document is not well formed", NULL);
|
||||
- xmlFreeDoc(ctxt->myDoc);
|
||||
- ctxt->myDoc = NULL;
|
||||
+ if(ctxt->myDoc != NULL) {
|
||||
+ xmlFreeDoc(ctxt->myDoc);
|
||||
+ ctxt->myDoc = NULL;
|
||||
+ }
|
||||
xmlFreeParserCtxt(ctxt);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/* done */
|
||||
res = ctxt->myDoc;
|
||||
+ ctxt->myDoc = NULL;
|
||||
xmlFreeParserCtxt(ctxt);
|
||||
return(res);
|
||||
|
||||
@@ -495,9 +510,14 @@ xmlSecParseMemoryExt(const xmlSecByte *prefix, xmlSecSize prefixSize,
|
||||
goto done;
|
||||
}
|
||||
doc = ctxt->myDoc;
|
||||
+ ctxt->myDoc = NULL;
|
||||
|
||||
done:
|
||||
if(ctxt != NULL) {
|
||||
+ if(ctxt->myDoc != NULL) {
|
||||
+ xmlFreeDoc(ctxt->myDoc);
|
||||
+ ctxt->myDoc = NULL;
|
||||
+ }
|
||||
xmlFreeParserCtxt(ctxt);
|
||||
}
|
||||
return(doc);
|
||||
@@ -536,20 +556,27 @@ xmlSecParseMemory(const xmlSecByte *buffer, xmlSecSize size, int recovery) {
|
||||
ret = xmlParseDocument(ctxt);
|
||||
if(ret < 0) {
|
||||
xmlSecXmlParserError("xmlParseDocument", ctxt, NULL);
|
||||
+ if(ctxt->myDoc != NULL) {
|
||||
+ xmlFreeDoc(ctxt->myDoc);
|
||||
+ ctxt->myDoc = NULL;
|
||||
+ }
|
||||
xmlFreeParserCtxt(ctxt);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
if(!(ctxt->wellFormed) && !recovery) {
|
||||
xmlSecInternalError("document is not well formed", NULL);
|
||||
- xmlFreeDoc(ctxt->myDoc);
|
||||
- ctxt->myDoc = NULL;
|
||||
+ if(ctxt->myDoc != NULL) {
|
||||
+ xmlFreeDoc(ctxt->myDoc);
|
||||
+ ctxt->myDoc = NULL;
|
||||
+ }
|
||||
xmlFreeParserCtxt(ctxt);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/* done */
|
||||
res = ctxt->myDoc;
|
||||
+ ctxt->myDoc = NULL;
|
||||
xmlFreeParserCtxt(ctxt);
|
||||
return(res);
|
||||
}
|
||||
diff --git a/src/xslt.c b/src/xslt.c
|
||||
index 2f43e41..1822cdc 100644
|
||||
--- a/src/xslt.c
|
||||
+++ b/src/xslt.c
|
||||
@@ -219,6 +219,10 @@ xmlSecXsltFinalize(xmlSecTransformPtr transform) {
|
||||
xsltFreeStylesheet(ctx->xslt);
|
||||
}
|
||||
if(ctx->parserCtx != NULL) {
|
||||
+ if(ctx->parserCtx->myDoc != NULL) {
|
||||
+ xmlFreeDoc(ctx->parserCtx->myDoc);
|
||||
+ ctx->parserCtx->myDoc = NULL;
|
||||
+ }
|
||||
xmlFreeParserCtxt(ctx->parserCtx);
|
||||
}
|
||||
memset(ctx, 0, sizeof(xmlSecXsltCtx));
|
||||
--
|
||||
1.7.12.4
|
||||
|
||||
@ -1,55 +0,0 @@
|
||||
Please see this bug report for full details:
|
||||
https://github.com/lsh123/xmlsec/issues/164
|
||||
|
||||
commit e303e077fb3e13654ba711b2816ff1a94247338b
|
||||
Author: lsh123 <aleksey@aleksey.com>
|
||||
Date: Wed Apr 11 17:13:43 2018 -1000
|
||||
|
||||
Add missing return(-1). (#165)
|
||||
|
||||
Fixed issue #164. All other crypto libraries are ok.
|
||||
|
||||
diff --git a/src/openssl/x509.c b/src/openssl/x509.c
|
||||
index 15fe70db..b98e62d1 100644
|
||||
--- a/src/openssl/x509.c
|
||||
+++ b/src/openssl/x509.c
|
||||
@@ -870,6 +870,7 @@ xmlSecOpenSSLX509DataNodeRead(xmlSecKeyDataPtr data, xmlNodePtr node, xmlSecKeyI
|
||||
xmlSecInternalError2("xmlSecOpenSSLX509CertificateNodeRead",
|
||||
xmlSecKeyDataGetName(data),
|
||||
"node=%s", xmlSecErrorsSafeString(xmlSecNodeGetName(cur)));
|
||||
+ return(-1);
|
||||
}
|
||||
} else if(xmlSecCheckNodeName(cur, xmlSecNodeX509SubjectName, xmlSecDSigNs)) {
|
||||
ret = xmlSecOpenSSLX509SubjectNameNodeRead(data, cur, keyInfoCtx);
|
||||
@@ -877,6 +878,7 @@ xmlSecOpenSSLX509DataNodeRead(xmlSecKeyDataPtr data, xmlNodePtr node, xmlSecKeyI
|
||||
xmlSecInternalError2("xmlSecOpenSSLX509SubjectNameNodeRead",
|
||||
xmlSecKeyDataGetName(data),
|
||||
"node=%s", xmlSecErrorsSafeString(xmlSecNodeGetName(cur)));
|
||||
+ return(-1);
|
||||
}
|
||||
} else if(xmlSecCheckNodeName(cur, xmlSecNodeX509IssuerSerial, xmlSecDSigNs)) {
|
||||
ret = xmlSecOpenSSLX509IssuerSerialNodeRead(data, cur, keyInfoCtx);
|
||||
@@ -884,6 +886,7 @@ xmlSecOpenSSLX509DataNodeRead(xmlSecKeyDataPtr data, xmlNodePtr node, xmlSecKeyI
|
||||
xmlSecInternalError2("xmlSecOpenSSLX509IssuerSerialNodeRead",
|
||||
xmlSecKeyDataGetName(data),
|
||||
"node=%s", xmlSecErrorsSafeString(xmlSecNodeGetName(cur)));
|
||||
+ return(-1);
|
||||
}
|
||||
} else if(xmlSecCheckNodeName(cur, xmlSecNodeX509SKI, xmlSecDSigNs)) {
|
||||
ret = xmlSecOpenSSLX509SKINodeRead(data, cur, keyInfoCtx);
|
||||
@@ -891,6 +894,7 @@ xmlSecOpenSSLX509DataNodeRead(xmlSecKeyDataPtr data, xmlNodePtr node, xmlSecKeyI
|
||||
xmlSecInternalError2("xmlSecOpenSSLX509SKINodeRead",
|
||||
xmlSecKeyDataGetName(data),
|
||||
"node=%s", xmlSecErrorsSafeString(xmlSecNodeGetName(cur)));
|
||||
+ return(-1);
|
||||
}
|
||||
} else if(xmlSecCheckNodeName(cur, xmlSecNodeX509CRL, xmlSecDSigNs)) {
|
||||
ret = xmlSecOpenSSLX509CRLNodeRead(data, cur, keyInfoCtx);
|
||||
@@ -898,6 +902,7 @@ xmlSecOpenSSLX509DataNodeRead(xmlSecKeyDataPtr data, xmlNodePtr node, xmlSecKeyI
|
||||
xmlSecInternalError2("xmlSecOpenSSLX509CRLNodeRead",
|
||||
xmlSecKeyDataGetName(data),
|
||||
"node=%s", xmlSecErrorsSafeString(xmlSecNodeGetName(cur)));
|
||||
+ return(-1);
|
||||
}
|
||||
} else if((keyInfoCtx->flags & XMLSEC_KEYINFO_FLAGS_X509DATA_STOP_ON_UNKNOWN_CHILD) != 0) {
|
||||
/* laxi schema validation: ignore unknown nodes */
|
||||
Binary file not shown.
BIN
xmlsec1-1.2.29.tar.gz
Normal file
BIN
xmlsec1-1.2.29.tar.gz
Normal file
Binary file not shown.
11
xmlsec1.spec
11
xmlsec1.spec
@ -1,15 +1,11 @@
|
||||
Name: xmlsec1
|
||||
Version: 1.2.25
|
||||
Release: 7
|
||||
Version: 1.2.29
|
||||
Release: 1
|
||||
Summary: A C library based on LibXML2
|
||||
License: MIT
|
||||
URL: http://www.aleksey.com/xmlsec
|
||||
Source0: http://www.aleksey.com/xmlsec/download/xmlsec1-%{version}.tar.gz
|
||||
|
||||
# Path1 get from fedora
|
||||
Patch1: xmlSecOpenSSLX509DataNodeRead-error.patch
|
||||
Patch6000: fix-xmlSecParseMemory-memory-leak-issue-199-202.patch
|
||||
|
||||
BuildRequires: pkgconfig(libxml-2.0) >= 2.8.0 pkgconfig(libxslt) >= 1.0.20 pkgconfig(openssl) >= 1.0.0
|
||||
BuildRequires: pkgconfig(nss) >= 3.11.1 pkgconfig(nspr) >= 4.4.1 libgcrypt-devel >= 1.4.0 libtool
|
||||
BuildRequires: pkgconfig(gnutls) >= 2.8.0 libtool-ltdl-devel autoconf automake gettext-devel
|
||||
@ -79,6 +75,9 @@ mv %{buildroot}%{_docdir}/xmlsec1/* __tmp_doc
|
||||
%{_mandir}/man1/*.1.*
|
||||
|
||||
%changelog
|
||||
* Fri Jan 10 2019 openEuler Buildteam <buildteam@openeuler.org> - 1.2.29-1
|
||||
- Update to 1.2.29
|
||||
|
||||
* Mon Dec 16 2019 openEuler Buildteam <buildteam@openeuler.org> - 1.2.25-7
|
||||
- Fix xmlSecParseMemory() memory leak
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user