com php-src: Fix bug #77849 Disable cloning of PDO handle/connection objects to avoid segfault: NEWS ext/pdo/pdo_dbh.c ext/pdo /tests/bug_77849.phpt
| From: | Joe Watkins | Date: | Fri, 05 Apr 2019 22:54:59 +0000 |
| Subject: | com php-src: Fix bug #77849 Disable cloning of PDO handle/connection objects to avoid segfault: NEWS ext/pdo/pdo_dbh.c ext/pdo /tests/bug_77849.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-105535@lists.php.net to get a copy of this message | ||
Commit: 9ec1525eb5840f8a38470df65f3a36b43eaf28f0
Author: Cameron Porter <porterca@us.ibm.com> Fri, 5 Apr 2019 13:42:04 -0500
Committer: Joe Watkins <krakjoe@php.net> Sat, 6 Apr 2019 00:54:59 +0200
Parents: 7b0ed8975dfaa7c2bbf1480c8633efeb450be78e
Branches: PHP-7.2 PHP-7..3 PHP-7.4 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=9ec1525eb5840f8a38470df65f3a36b43eaf28f0
Log:
Fix bug #77849 Disable cloning of PDO handle/connection objects to avoid segfault
Bugs:
https://bugs.php.net/77849
Changed paths:
M NEWS
M ext/pdo/pdo_dbh.c
A ext/pdo/tests/bug_77849.phpt
Diff:
diff --git a/NEWS b/NEWS
index 67028cd..d355778 100644
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,10 @@ PHP NEWS
. Fixed bug #77827 (preg_match does not ignore \r in regex flags). (requinix,
cmb)
+- PDO:
+ . Fixed bug #77849 (Disable cloning of PDO handle/connection objects).
+ (camporter)
+
- phpdbg:
. Fixed bug #76801 (too many open files).. (alekitto)
. Fixed bug #77800 (phpdbg segfaults on listing some conditional breakpoints).
diff --git a/ext/pdo/pdo_dbh.c b/ext/pdo/pdo_dbh.c
index 314c845..5ce220a 100644
--- a/ext/pdo/pdo_dbh.c
+++ b/ext/pdo/pdo_dbh.c
@@ -1403,6 +1403,7 @@ void pdo_dbh_init(void)
pdo_dbh_object_handlers.offset = XtOffsetOf(pdo_dbh_object_t, std);
pdo_dbh_object_handlers.dtor_obj = zend_objects_destroy_object;
pdo_dbh_object_handlers.free_obj = pdo_dbh_free_storage;
+ pdo_dbh_object_handlers..clone_obj = NULL;
pdo_dbh_object_handlers.get_method = dbh_method_get;
pdo_dbh_object_handlers.compare_objects = dbh_compare;
pdo_dbh_object_handlers.get_gc = dbh_get_gc;
diff --git a/ext/pdo/tests/bug_77849.phpt b/ext/pdo/tests/bug_77849.phpt
new file mode 100644
index 0000000..6643f8c
--- /dev/null
+++ b/ext/pdo/tests/bug_77849.phpt
@@ -0,0 +1,23 @@
+--TEST--
+PDO Common: Bug #77849 (Unexpected segfault attempting to use cloned PDO object)
+--SKIPIF--
+<?php
+if (!extension_loaded('pdo')) die('skip');
+$dir = getenv('REDIR_TEST_DIR');
+if (false == $dir) die('skip no driver');
+require_once $dir . 'pdo_test.inc';
+PDOTest::skip();
+?>
+--FILE--
+<?php
+if (getenv('REDIR_TEST_DIR') === false)
putenv('REDIR_TEST_DIR='.dirname(__FILE__) . '/../../pdo/tests/');
+require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
+
+$db = PDOTest::factory();
+$db2 = clone $db;
+?>
+--EXPECTF--
+Fatal error: Uncaught Error: Trying to clone an uncloneable object of class PDO in %s
+Stack trace:
+#0 {main}
+ thrown in %s on line %d