Skip to content

Commit 3517702

Browse files
committed
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fix #78473: odbc_close() closes arbitrary resources
2 parents f912445 + 195b8ae commit 3517702

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
@@ -18,6 +18,9 @@ PHP NEWS
1818
. Fixed bug #78334 (fpm log prefix message includes wrong stdout/stderr
1919
notation). (Tsuyoshi Sadakata)
2020

21+
- ODBC:
22+
. Fixed bug #78473 (odbc_close() closes arbitrary resources). (cmb)
23+
2124
- SPL:
2225
. Fixed bug #78436 (Missing addref in SplPriorityQueue EXTR_BOTH mode).
2326
(Nikita)

ext/odbc/php_odbc.c

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

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

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)