We have to bail out, if an invalid resource is given. For consistency
with the other `zend_fetch_resource(2)` calls, we return `FALSE`.
. Fixed connect_attr issues and added the _server_host connection attribute.
(Qianqian Bu)
+- ODBC:
+ . Fixed bug #78473 (odbc_close() closes arbitrary resources). (cmb)
+
29 Aug 2019, PHP 7.2.22
- Core:
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;
}
--- /dev/null
+--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)