Skip to content

Commit 8417bc1

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Fix #78473: odbc_close() closes arbitrary resources
2 parents ad66137 + 3517702 commit 8417bc1

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

ext/odbc/php_odbc.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2440,7 +2440,10 @@ PHP_FUNCTION(odbc_close)
24402440
return;
24412441
}
24422442

2443-
conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_conn), "ODBC-Link", le_conn, le_pconn);
2443+
if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_conn), "ODBC-Link", le_conn, le_pconn))) {
2444+
RETURN_FALSE;
2445+
}
2446+
24442447
if (Z_RES_P(pv_conn)->type == le_pconn) {
24452448
is_pconn = 1;
24462449
}

ext/odbc/tests/bug78473.phpt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
try {
10+
odbc_close(STDIN);
11+
} catch (TypeError $err) {
12+
echo $err->getMessage(), PHP_EOL;
13+
}
14+
var_dump(STDIN);
15+
?>
16+
--EXPECTF--
17+
odbc_close(): supplied resource is not a valid ODBC-Link resource
18+
resource(%d) of type (stream)

0 commit comments

Comments
 (0)