php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #73135
Patch bug73135.patch revision 2016-10-16 06:56 UTC by edgar dot r dot sandi at gmail dot com

Patch bug73135.patch for XML related Bug #73135

Patch version 2016-10-16 06:56 UTC

Return to Bug #73135 | Download this patch
Patch Revisions:

Developer: edgar.r.sandi@gmail.com

From f2a8a8c068995a5d780882c556cedd53bce3827d Mon Sep 17 00:00:00 2001
From: "Edgar R. Sandi" <edgar.r.sandi@gmail.com>
Date: Sat, 15 Oct 2016 23:58:35 -0300
Subject: [PATCH 1/3] fixes bug #73135

---
 ext/xml/compat.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/ext/xml/compat.c b/ext/xml/compat.c
index 3fc203e..23db0ca 100644
--- a/ext/xml/compat.c
+++ b/ext/xml/compat.c
@@ -593,13 +593,13 @@ has been defined and none can be detected */
 	}
 #endif
 
+	if (parser->parser->lastError.level >= XML_ERR_WARNING) {
+		return 0;
+	}
+
 	error = xmlParseChunk(parser->parser, (char *) data, data_len, is_final);
 	if (!error) {
 		return 1;
-	} else if (parser->parser->lastError.level > XML_ERR_WARNING ){
-		return 0;
-	} else {
-		return 1;
 	}
 }
 
-- 
2.9.2


From 716676b6062881d051bbac71494e592527ef2a69 Mon Sep 17 00:00:00 2001
From: "Edgar R. Sandi" <edgar.r.sandi@gmail.com>
Date: Sun, 16 Oct 2016 01:06:23 -0200
Subject: [PATCH 2/3] phpt file to bug #73135

---
 ext/xml/tests/bug73135.phpt | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 ext/xml/tests/bug73135.phpt

diff --git a/ext/xml/tests/bug73135.phpt b/ext/xml/tests/bug73135.phpt
new file mode 100644
index 0000000..5fb43e9
--- /dev/null
+++ b/ext/xml/tests/bug73135.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Bug #73135 (xml_parse() segmentation fault)
+--CREDITS--
+edgarsandi - <edgar.r.sandi@gmail.com>
+--FILE--
+<?php
+    function start_elem($parser, $xml) {
+        xml_parse($parser, $xml);
+    }
+
+    $xml = <<<HERE
+    <a xmlns="ahihi">
+        <bar foo="ahihi"/>
+    </a>
+HERE;
+
+    $parser = xml_parser_create_ns();
+    xml_set_element_handler($parser, 'start_elem', 'ahihi');
+    xml_parse($parser, $xml);
+?>
+--EXPECTF--
+Warning: xml_parse(): Unable to call handler ahihi() in %s%ebug73135.php on line %d
+
+Warning: xml_parse(): Unable to call handler ahihi() in %s%ebug73135.php on line %d
\ No newline at end of file
-- 
2.9.2


From 0f4655a1bcf9538ae26f8cfc46b1b72c327b2b45 Mon Sep 17 00:00:00 2001
From: "Edgar R. Sandi" <edgar.r.sandi@gmail.com>
Date: Sun, 16 Oct 2016 04:15:47 -0200
Subject: [PATCH 3/3] fixed bug generated by fixes bug #73135

---
 ext/xml/compat.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/ext/xml/compat.c b/ext/xml/compat.c
index 23db0ca..d39afac 100644
--- a/ext/xml/compat.c
+++ b/ext/xml/compat.c
@@ -598,7 +598,9 @@ has been defined and none can be detected */
 	}
 
 	error = xmlParseChunk(parser->parser, (char *) data, data_len, is_final);
-	if (!error) {
+	if (error) {
+		return 0;
+	} else {
 		return 1;
 	}
 }
-- 
2.9.2

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 05 20:01:29 2024 UTC