diff options
author | Christoph M. Becker <cmbecker69@gmx.de> | 2019-08-28 17:58:13 +0200 |
---|---|---|
committer | Christoph M. Becker <cmbecker69@gmx.de> | 2019-08-28 17:58:35 +0200 |
commit | 35177027f4e9364b70d436a544c9b9d0d183b5ca (patch) | |
tree | 79131751a519dbb5d36b382580ea2d4343cb0b65 | |
parent | f912445eb21c74403e3e7a827cc14094c66fefd6 (diff) | |
parent | 195b8ae7791c9f556cd26ceb5f5d6eca91ac47ca (diff) | |
download | php-git-35177027f4e9364b70d436a544c9b9d0d183b5ca.tar.gz |
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
Fix #78473: odbc_close() closes arbitrary resources
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | ext/odbc/php_odbc.c | 5 | ||||
-rw-r--r-- | ext/odbc/tests/bug78473.phpt | 14 |
3 files changed, 21 insertions, 1 deletions
@@ -18,6 +18,9 @@ PHP NEWS . Fixed bug #78334 (fpm log prefix message includes wrong stdout/stderr notation). (Tsuyoshi Sadakata) +- ODBC: + . Fixed bug #78473 (odbc_close() closes arbitrary resources). (cmb) + - SPL: . Fixed bug #78436 (Missing addref in SplPriorityQueue EXTR_BOTH mode). (Nikita) diff --git a/ext/odbc/php_odbc.c b/ext/odbc/php_odbc.c index 6bd24781b4..19fce8d0fd 100644 --- a/ext/odbc/php_odbc.c +++ b/ext/odbc/php_odbc.c @@ -2694,7 +2694,10 @@ PHP_FUNCTION(odbc_close) return; } - conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_conn), "ODBC-Link", le_conn, le_pconn); + if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_conn), "ODBC-Link", le_conn, le_pconn))) { + RETURN_FALSE; + } + if (Z_RES_P(pv_conn)->type == le_pconn) { is_pconn = 1; } diff --git a/ext/odbc/tests/bug78473.phpt b/ext/odbc/tests/bug78473.phpt new file mode 100644 index 0000000000..fd73b6cc07 --- /dev/null +++ b/ext/odbc/tests/bug78473.phpt @@ -0,0 +1,14 @@ +--TEST-- +Bug #78473 (odbc_close() closes arbitrary resources) +--SKIPIF-- +<?php +if (!extension_loaded('odbc')) die('skip odbc extension not available'); +?> +--FILE-- +<?php +odbc_close(STDIN); +var_dump(STDIN); +?> +--EXPECTF-- +Warning: odbc_close(): supplied resource is not a valid ODBC-Link resource in %s on line %d +resource(%d) of type (stream) |