Skip to content

[PDO] Bound-check column index in getColumnMeta() - #301

Closed
iliaal wants to merge 1 commit into
PHP-8.4from
fix/pdo-getcolumnmeta-bounds-84
Closed

[PDO] Bound-check column index in getColumnMeta()#301
iliaal wants to merge 1 commit into
PHP-8.4from
fix/pdo-getcolumnmeta-bounds-84

Conversation

@iliaal

@iliaal iliaal commented Aug 24, 2026

Copy link
Copy Markdown
Owner

PDOStatement::getColumnMeta() indexed stmt->columns[colno] as soon as the driver get_column_meta hook reported success, without checking that columns had been described or that colno was below column_count, so a driver returning unconditional success (e.g. pdo_odbc) segfaulted on an unexecuted statement and read out of bounds for an oversized index. The patch rejects both cases with ValueError like the fetch paths do, keeping the existing bool(false) behavior of drivers that report failure themselves. Sibling audit found all other stmt->columns[] accesses inside describe_columns() loops or bound-checked paths.

getColumnMeta() indexed stmt->columns[colno] as soon as the driver
get_column_meta hook reported success, without verifying that columns
had been described or that colno was below column_count, so a driver
returning unconditional success made an unexecuted statement segfault
and an oversized index read out of bounds. Reject both cases with
ValueError like the fetch paths do. Sibling audit: all other
stmt->columns[] sites are inside describe_columns() loops or
bound-checked paths.
@iliaal
iliaal force-pushed the fix/pdo-getcolumnmeta-bounds-84 branch from e07296e to 731ecbc Compare September 10, 2026 22:10
@iliaal

iliaal commented Sep 10, 2026

Copy link
Copy Markdown
Owner Author

Upstream: php#23654

@iliaal iliaal closed this Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant