Skip to content

Commit f1d8395

Browse files
committedSep 28, 2020
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fix #67465: NULL Pointer dereference in odbc_handle_preparer
2 parents ef385e8 + 6acfb79 commit f1d8395

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed
 

‎NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ PHP NEWS
2727
. Updated to PCRE 10.35. (cmb)
2828
. Fixed bug #80118 (Erroneous whitespace match with JIT only). (cmb)
2929

30+
- PDO_ODBC:
31+
. Fixed bug #67465 (NULL Pointer dereference in odbc_handle_preparer). (cmb)
32+
3033
- Standard:
3134
. Fixed bug #80114 (parse_url does not accept URLs with port 0). (cmb, twosee)
3235
. Fixed bug #76943 (Inconsistent stream_wrapper_restore() errors). (cmb)

‎ext/pdo_odbc/odbc_driver.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,8 @@ static int odbc_handle_preparer(pdo_dbh_t *dbh, const char *sql, size_t sql_len,
179179
return 0;
180180
}
181181

182+
stmt->driver_data = S;
183+
182184
cursor_type = pdo_attr_lval(driver_options, PDO_ATTR_CURSOR, PDO_CURSOR_FWDONLY);
183185
if (cursor_type != PDO_CURSOR_FWDONLY) {
184186
rc = SQLSetStmtAttr(S->stmt, SQL_ATTR_CURSOR_SCROLLABLE, (void*)SQL_SCROLLABLE, 0);
@@ -197,7 +199,6 @@ static int odbc_handle_preparer(pdo_dbh_t *dbh, const char *sql, size_t sql_len,
197199
efree(nsql);
198200
}
199201

200-
stmt->driver_data = S;
201202
stmt->methods = &odbc_stmt_methods;
202203

203204
if (rc != SQL_SUCCESS) {

‎ext/pdo_odbc/tests/bug67465.phpt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
Bug #67465 (NULL Pointer dereference in odbc_handle_preparer)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('pdo_odbc')) die('skip pdo_odbc extension not available');
6+
require 'ext/pdo/tests/pdo_test.inc';
7+
PDOTest::skip();
8+
?>
9+
--FILE--
10+
<?php
11+
require 'ext/pdo/tests/pdo_test.inc';
12+
$db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
13+
$db->prepare("SELECT 1", [PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL]);
14+
echo "done\n";
15+
?>
16+
--EXPECT--
17+
done

0 commit comments

Comments
 (0)
Please sign in to comment.