com php-src: Fix #78025: segfault when accessing properties of DOMDocumentType: NEWS ext/dom/documenttype.c ext/dom/tests/bug78025.phpt
| From: | Christoph Michael Becker | Date: | Fri, 17 May 2019 11:31:18 +0000 |
| Subject: | com php-src: Fix #78025: segfault when accessing properties of DOMDocumentType: NEWS ext/dom/documenttype.c ext/dom/tests/bug78025.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-106222@lists.php.net to get a copy of this message | ||
Commit: e246dea9fe4d679f20de298c753d9ad083dbad68
Author: Christoph M. Becker <cmbecker69@gmx.de> Fri, 17 May 2019 13:31:18 +0200
Parents: 35353dc49a73a58c17c7896c4c4c3997ef2c007d
Branches: PHP-7.2 PHP-7..3 PHP-7.4 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=e246dea9fe4d679f20de298c753d9ad083dbad68
Log:
Fix #78025: segfault when accessing properties of DOMDocumentType
Instead of following the NULL pointer, we return an empty string.
Bugs:
https://bugs.php.net/78025
Changed paths:
M NEWS
M ext/dom/documenttype.c
A ext/dom/tests/bug78025.phpt
Diff:
diff --git a/NEWS b/NEWS
index eb52e52..2135a42 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,10 @@ PHP NEWS
. Fixed bug #76980 (Interface gets skipped if autoloader throws an exception).
(Nikita)
+- DOM:
+ . Fixed bug #78025 (segfault when accessing properties of DOMDocumentType).
+ (cmb)
+
30 May 2019, PHP 7.2.19
- FPM:
diff --git a/ext/dom/documenttype.c b/ext/dom/documenttype.c
index 661d23d..d261d26 100644
--- a/ext/dom/documenttype.c
+++ b/ext/dom/documenttype.c
@@ -52,7 +52,7 @@ int dom_documenttype_name_read(dom_object *obj, zval *retval)
return FAILURE;
}
- ZVAL_STRING(retval, (char *) (dtdptr->name));
+ ZVAL_STRING(retval, dtdptr->name ? (char *) (dtdptr->name) : "");
return SUCCESS;
}
diff --git a/ext/dom/tests/bug78025.phpt b/ext/dom/tests/bug78025.phpt
new file mode 100644
index 0000000..0a12d9f
--- /dev/null
+++ b/ext/dom/tests/bug78025.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Bug #78025 (segfault when accessing properties of DOMDocumentType)
+--SKIPIF--
+<?php
+if (!extension_loaded('dom')) die('skip dom extension not available');
+?>
+--FILE--
+<?php
+$htm = "<!DOCTYPE><html></html>";
+$dom = new DOMDocument;
+$dom->loadHTML($htm);
+var_dump($dom->doctype->name);
+?>
+===DONE===
+--EXPECTF--
+Warning: DOMDocument::loadHTML(): htmlParseDocTypeDecl : no DOCTYPE name ! in Entity, line: 1 in %s
on line %d
+string(0) ""
+===DONE===