Skip to content

Fix GH-20726: crash in pdo_odbc with pooling and no credentials - #22512

Merged
NattyNarwhal merged 1 commit into
php:PHP-8.4from
iliaal:fix/gh-20726-pdo-odbc-null-creds
Jun 30, 2026
Merged

NattyNarwhal merged 1 commit into
php:PHP-8.4from
iliaal:fix/gh-20726-pdo-odbc-null-creds

Conversation

@iliaal

@iliaal iliaal commented Jun 29, 2026

Copy link
Copy Markdown
Member

pdo_odbc passed dbh->username and dbh->password straight to SQLConnect, and both are NULL when the DSN carries no credentials. With ODBC connection pooling enabled, the unixODBC driver manager runs strcmp() on the cached and requested credentials while matching a pooled connection, dereferences the NULL, and crashes inside SQLConnect. Passing empty strings avoids it. Reproduced on PHP-8.4 against the MDBTools driver with pooling enabled: a connect/close loop SIGSEGVs unpatched and runs clean patched. This hardens the PHP side only; the residual fault under pooling is an uninitialised-value read inside unixODBC's own pool bookkeeping and belongs upstream. Refs #20726

@NattyNarwhal NattyNarwhal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a comment explaining why in source, but looks OK. We should also file upstream to unixODBC too...

When a DSN carries no credentials, dbh->username and dbh->password are
NULL. With ODBC connection pooling enabled, the unixODBC driver manager
compares the cached and requested credentials with strcmp() while
matching a pooled connection, dereferencing the NULL pointers and
crashing inside SQLConnect. Pass empty strings instead. This hardens the
connect path; the pooling use-after-free in phpGH-20726 is a separate
unixODBC defect.
@iliaal
iliaal force-pushed the fix/gh-20726-pdo-odbc-null-creds branch from 13e1da3 to a5a9e9e Compare June 29, 2026 23:27
@iliaal

iliaal commented Jun 29, 2026 •

Copy link
Copy Markdown
Member Author

Added the comment and PR for upstream lib as well.

@NattyNarwhal
NattyNarwhal merged commit c8d90e7 into php:PHP-8.4 Jun 30, 2026
18 checks passed
iliaal added a commit that referenced this pull request Jun 30, 2026
* PHP-8.5:
  Fix GH-20726: crash in pdo_odbc with pooling and no credentials (#22512)
pull Bot pushed a commit to edisplay/php-src that referenced this pull request Jun 30, 2026
* PHP-8.4:
  Fix phpGH-20726: crash in pdo_odbc with pooling and no credentials (php#22512)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants