[php-src] master: Merge branch 'PHP-8.6'
| From: | Ilia Alshanetsky | Date: | Fri, 30 Oct 2026 00:11:36 +0000 |
| Subject: | [php-src] master: Merge branch 'PHP-8.6' | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-142969@lists.php.net to get a copy of this message | ||
Author: Ilia Alshanetsky (iliaal)
Date: 2026-10-29T20:10:19-04:00
Commit: https://github.com/php/php-src/commit/d306eb237c67aa28d1beda6baf8c3d10ae453c89
Raw diff: https://github.com/php/php-src/commit/d306eb237c67aa28d1beda6baf8c3d10ae453c89.diff
Merge branch 'PHP-8.6'
Changed paths:
A ext/pdo_firebird/tests/gh25006.phpt
M ext/pdo_firebird/firebird_statement.c
Diff:
diff --git a/ext/pdo_firebird/firebird_statement.c b/ext/pdo_firebird/firebird_statement.c
index 6f6a4fa8610f..f1e60e25b41b 100644
--- a/ext/pdo_firebird/firebird_statement.c
+++ b/ext/pdo_firebird/firebird_statement.c
@@ -332,9 +332,15 @@ static int pdo_firebird_stmt_describe(pdo_stmt_t *stmt, int colno) /* {{{ */
static int pdo_firebird_stmt_get_column_meta(pdo_stmt_t *stmt, zend_long colno, zval *return_value)
{
pdo_firebird_stmt *S = (pdo_firebird_stmt *) stmt->driver_data;
- XSQLVAR *var = &S->out_sqlda.sqlvar[colno];
-
+ XSQLVAR *var;
enum pdo_param_type param_type;
+
+ if (colno >= stmt->column_count) {
+ ZVAL_EMPTY_ARRAY(return_value);
+ return 1;
+ }
+
+ var = &S->out_sqlda.sqlvar[colno];
if (var->sqlscale < 0) {
param_type = PDO_PARAM_STR;
} else {
diff --git a/ext/pdo_firebird/tests/gh25006.phpt b/ext/pdo_firebird/tests/gh25006.phpt
new file mode 100644
index 000000000000..d0e9918322a2
--- /dev/null
+++ b/ext/pdo_firebird/tests/gh25006.phpt
@@ -0,0 +1,73 @@
+--TEST--
+GH-25006 (PDO_Firebird::getColumnMeta() reads out of bounds for an out-of-range column index)
+--EXTENSIONS--
+pdo_firebird
+--SKIPIF--
+<?php
+require 'skipif.inc';
+?>
+--XLEAK--
+A bug in firebird causes a memory leak when calling
isc_attach_database().
+See https://github.com/FirebirdSQL/firebird/issues/7849
+--FILE--
+<?php
+require 'testdb.inc';
+
+$dbh = getDbConnection();
+$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+
+$stmt = $dbh->prepare('SELECT 1 AS one, 2 AS two FROM RDB$DATABASE');
+
+echo "before execute: ";
+try {
+ var_dump($stmt->getColumnMeta(2));
+} catch (Throwable $e) {
+ echo $e::class, ': ', $e->getMessage(), "\n";
+}
+
+$stmt->execute();
+
+echo "column 0: ";
+$meta = $stmt->getColumnMeta(0);
+echo $meta['name'], ' ', $meta['pdo_type'], "\n";
+
+echo "column 1: ";
+$meta = $stmt->getColumnMeta(1);
+echo $meta['name'], ' ', $meta['pdo_type'], "\n";
+
+foreach ([2, 1000000] as $col) {
+ echo "column $col: ";
+ try {
+ var_dump($stmt->getColumnMeta($col));
+ } catch (Throwable $e) {
+ echo $e::class, ': ', $e->getMessage(), "\n";
+ }
+}
+
+echo "no output columns: ";
+$empty = $dbh->prepare('EXECUTE BLOCK AS BEGIN END');
+echo $empty->columnCount(), ' ';
+try {
+ var_dump($empty->getColumnMeta(0));
+} catch (Throwable $e) {
+ echo $e::class, ': ', $e->getMessage(), "\n";
+}
+
+echo "negative: ";
+try {
+ var_dump($stmt->getColumnMeta(-1));
+} catch (Throwable $e) {
+ echo $e::class, ': ', $e->getMessage(), "\n";
+}
+
+echo "done\n";
+?>
+--EXPECT--
+before execute: PDOException: SQLSTATE[07009]: Invalid descriptor index: invalid column index
+column 0: ONE 1
+column 1: TWO 1
+column 2: PDOException: SQLSTATE[07009]: Invalid descriptor index: invalid column index
+column 1000000: PDOException: SQLSTATE[07009]: Invalid descriptor index: invalid column index
+no output columns: 0 PDOException: SQLSTATE[07009]: Invalid descriptor index: invalid column index
+negative: ValueError: PDOStatement::getColumnMeta(): Argument #1 ($column) must be greater than or
equal to 0
+done