Skip to content

Commit 195b8ae

Browse files
committed
Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2: Fix #78473: odbc_close() closes arbitrary resources
2 parents 5748cec + b557265 commit 195b8ae

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ PHP NEWS
2323
. Fixed connect_attr issues and added the _server_host connection attribute.
2424
(Qianqian Bu)
2525

26+
- ODBC:
27+
. Fixed bug #78473 (odbc_close() closes arbitrary resources). (cmb)
28+
2629
29 Aug 2019, PHP 7.3.9
2730

2831
- Core:

ext/odbc/php_odbc.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2695,7 +2695,10 @@ PHP_FUNCTION(odbc_close)
26952695
return;
26962696
}
26972697

2698-
conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_conn), "ODBC-Link", le_conn, le_pconn);
2698+
if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_conn), "ODBC-Link", le_conn, le_pconn))) {
2699+
RETURN_FALSE;
2700+
}
2701+
26992702
if (Z_RES_P(pv_conn)->type == le_pconn) {
27002703
is_pconn = 1;
27012704
}

ext/odbc/tests/bug78473.phpt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
Bug #78473 (odbc_close() closes arbitrary resources)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('odbc')) die('skip odbc extension not available');
6+
?>
7+
--FILE--
8+
<?php
9+
odbc_close(STDIN);
10+
var_dump(STDIN);
11+
?>
12+
--EXPECTF--
13+
Warning: odbc_close(): supplied resource is not a valid ODBC-Link resource in %s on line %d
14+
resource(%d) of type (stream)

0 commit comments

Comments
 (0)