]> granicus.if.org Git - php/commitdiff
Fix #80152: odbc_execute() moves internal pointer of $params
authorChristoph M. Becker <cmbecker69@gmx.de>
Sat, 26 Sep 2020 11:14:40 +0000 (13:14 +0200)
committerChristoph M. Becker <cmbecker69@gmx.de>
Tue, 29 Sep 2020 09:34:48 +0000 (11:34 +0200)
As least intrusive fix, we separate the passed array argument.

Closes GH-6219.

NEWS
ext/odbc/php_odbc.c
ext/odbc/tests/bug80152.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 923d95cd5cf3003954f73fb534c143b223ae5087..a090a64eee8193dcabe08ed4fa810ac13b1e672e 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -17,6 +17,7 @@ PHP                                                                        NEWS
   . Fixed bug #80147 (BINARY strings may not be properly zero-terminated).
     (cmb)
   . Fixed bug #80150 (Failure to fetch error message). (cmb)
+  . Fixed bug #80152 (odbc_execute() moves internal pointer of $params). (cmb)
 
 - OPcache:
   . Fixed bug #80083 (Optimizer pass 6 removes variables used for ibm_db2 data
index e26368dfebabbd003b9b3653ab70c82756f9aceb..0722a91e3449e18db22a333abdc97a45b9213587 100644 (file)
@@ -1309,7 +1309,7 @@ PHP_FUNCTION(odbc_execute)
        int numArgs = ZEND_NUM_ARGS(), i, ne;
        RETCODE rc;
 
-       if (zend_parse_parameters(numArgs, "r|a", &pv_res, &pv_param_arr) == FAILURE) {
+       if (zend_parse_parameters(numArgs, "r|a/", &pv_res, &pv_param_arr) == FAILURE) {
                return;
        }
 
diff --git a/ext/odbc/tests/bug80152.phpt b/ext/odbc/tests/bug80152.phpt
new file mode 100644 (file)
index 0000000..719ec3a
--- /dev/null
@@ -0,0 +1,26 @@
+--TEST--
+Bug #80152 (odbc_execute() moves internal pointer of $params)
+--SKIPIF--
+<?php include 'skipif.inc'; ?>
+--FILE--
+<?php
+include 'config.inc';
+
+$conn = odbc_connect($dsn, $user, $pass);
+odbc_exec($conn,"CREATE TABLE bug80152 (id INT, name CHAR(24))"); 
+$stmt = odbc_prepare($conn,"INSERT INTO bug80152 (id, name) VALUES (?, ?)");
+$params = [1, "John", "Lim"];
+var_dump(key($params));
+odbc_execute($stmt, $params);
+var_dump(key($params));
+?>
+--CLEAN--
+<?php
+include 'config.inc';
+
+$conn = odbc_connect($dsn, $user, $pass);
+odbc_exec($conn, "DROP TABLE bug80152");
+?>
+--EXPECT--
+int(0)
+int(0)