Skip to content

Fix heap over-read seeding the long-column buffer in pdo_odbc#95

Closed
iliaal wants to merge 1 commit into
PHP-8.5from
fix-pdo-odbc-long-overread
Closed

Fix heap over-read seeding the long-column buffer in pdo_odbc#95
iliaal wants to merge 1 commit into
PHP-8.5from
fix-pdo-odbc-long-overread

Conversation

@iliaal

@iliaal iliaal commented Jun 16, 2026

Copy link
Copy Markdown
Owner

In the long-column fetch path, when the ODBC driver reports the total column length rather than SQL_NO_TOTAL, the result string was seeded by copying orig_fetched_len + 1 bytes out of C->data, which holds at most LONG_COLUMN_BUFFER_SIZE bytes from the first SQLGetData. For a column larger than that buffer this reads past C->data. Seed only the bytes actually present, matching the SQL_NO_TOTAL branch; the remainder is still fetched by the loop.

In the long-column fetch path, when the ODBC driver reports the total
column length rather than SQL_NO_TOTAL, the result string was seeded by
copying orig_fetched_len + 1 bytes out of C->data, which holds at most
LONG_COLUMN_BUFFER_SIZE bytes from the first SQLGetData. For a column
larger than that buffer this reads past C->data. Seed only the bytes
actually present in the buffer, matching the SQL_NO_TOTAL branch; the
remainder is still fetched by the loop.
@iliaal

iliaal commented Jun 16, 2026

Copy link
Copy Markdown
Owner Author

Promoted upstream to php#22349 (base PHP-8.5). Closing this fork PR; keeping the branch since the upstream PR's head points at it.

@iliaal iliaal closed this Jun 16, 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