[libxslt] Fix double free in libexslt hash functions
- From: Nick Wellnhofer <nwellnhof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libxslt] Fix double free in libexslt hash functions
- Date: Wed, 20 Apr 2016 12:38:44 +0000 (UTC)
commit d8862309f08054218b28e2c8f5fb3cb2f650cac7
Author: Nick Wellnhofer <wellnhofer aevum de>
Date: Wed Apr 20 14:35:43 2016 +0200
Fix double free in libexslt hash functions
Thanks to Nicolas Gregoire for the report.
Fixes bug #765271:
https://bugzilla.gnome.org/show_bug.cgi?id=765271
libexslt/crypto.c | 15 +++------------
tests/exslt/crypto/hash.1.out | 2 ++
tests/exslt/crypto/hash.1.xml | 5 +++++
3 files changed, 10 insertions(+), 12 deletions(-)
---
diff --git a/libexslt/crypto.c b/libexslt/crypto.c
index 6aa9dd2..e13db8b 100644
--- a/libexslt/crypto.c
+++ b/libexslt/crypto.c
@@ -499,11 +499,8 @@ exsltCryptoMd4Function (xmlXPathParserContextPtr ctxt, int nargs) {
unsigned char hex[MD5_DIGEST_LENGTH * 2 + 1];
str_len = exsltCryptoPopString (ctxt, nargs, &str);
- if (str_len == 0) {
- xmlXPathReturnEmptyString (ctxt);
- xmlFree (str);
+ if (str_len == 0)
return;
- }
PLATFORM_HASH (ctxt, PLATFORM_MD4, (const char *) str, str_len,
(char *) hash);
@@ -532,11 +529,8 @@ exsltCryptoMd5Function (xmlXPathParserContextPtr ctxt, int nargs) {
unsigned char hex[MD5_DIGEST_LENGTH * 2 + 1];
str_len = exsltCryptoPopString (ctxt, nargs, &str);
- if (str_len == 0) {
- xmlXPathReturnEmptyString (ctxt);
- xmlFree (str);
+ if (str_len == 0)
return;
- }
PLATFORM_HASH (ctxt, PLATFORM_MD5, (const char *) str, str_len,
(char *) hash);
@@ -565,11 +559,8 @@ exsltCryptoSha1Function (xmlXPathParserContextPtr ctxt, int nargs) {
unsigned char hex[SHA1_DIGEST_LENGTH * 2 + 1];
str_len = exsltCryptoPopString (ctxt, nargs, &str);
- if (str_len == 0) {
- xmlXPathReturnEmptyString (ctxt);
- xmlFree (str);
+ if (str_len == 0)
return;
- }
PLATFORM_HASH (ctxt, PLATFORM_SHA1, (const char *) str, str_len,
(char *) hash);
diff --git a/tests/exslt/crypto/hash.1.out b/tests/exslt/crypto/hash.1.out
index a3b93d1..ce6f6ab 100644
--- a/tests/exslt/crypto/hash.1.out
+++ b/tests/exslt/crypto/hash.1.out
@@ -17,3 +17,5 @@ text = _Hello, World._ md5 = e9db5cf8349b1166e96a742e198a0dd1 sha1 = 179
text = _Hello, World9_ md5 = faf56df200d7f645a7911c4179614ca8 sha1 =
8a420fad2ccc0504448871245cb5769a42a16cdb
text = _Hello, WorldЖ_ md5 = ffa8f2b84083d767a672debbe535a68e sha1 =
4a57c7b5874d38a98b6de30496fd51894039334f
text = _Hello, WorldZ_ md5 = d6ec5883599d8ad6da7a32a094c1375b sha1 =
cdc052e9c8e42b61fd3d45c72211b4d0bafcd39f
+
+text = __ md5 = sha1 =
diff --git a/tests/exslt/crypto/hash.1.xml b/tests/exslt/crypto/hash.1.xml
index 57bf45f..a9a792d 100644
--- a/tests/exslt/crypto/hash.1.xml
+++ b/tests/exslt/crypto/hash.1.xml
@@ -23,4 +23,9 @@
<pattern>Hello, WorldЖ</pattern>
<pattern>Hello, WorldZ</pattern>
+ <br/>
+
+ <!-- Empty string. -->
+ <pattern/>
+
</patterns>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]