Skip to content

Commit 92c179e

Browse files
committed
Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4: Fix phpGH-20726: crash in pdo_odbc with pooling and no credentials (php#22512)
2 parents 643bd7f + c8d90e7 commit 92c179e

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ PHP NEWS
3232
- Lexbor:
3333
. Merge patch c3a6847. (ilutov, timwolla)
3434

35+
- PDO_ODBC:
36+
. Fixed bug GH-20726 (Crash with ODBC connection pooling when the DSN
37+
carries no credentials). (iliaal)
38+
3539
- Phar:
3640
. Fixed inconsistent handling of the magic ".phar" directory. Paths such as
3741
"/.phar" remain protected, while non-magic paths that merely start with

ext/pdo_odbc/odbc_driver.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,11 @@ static int pdo_odbc_handle_factory(pdo_dbh_t *dbh, zval *driver_options) /* {{{
605605
dsnbuf, sizeof(dsnbuf)-1, &dsnbuflen, SQL_DRIVER_NOPROMPT);
606606
}
607607
if (!use_direct) {
608-
rc = SQLConnect(H->dbc, (SQLCHAR *) dbh->data_source, SQL_NTS, (SQLCHAR *) dbh->username, SQL_NTS, (SQLCHAR *) dbh->password, SQL_NTS);
608+
/* unixODBC pooling strcmp()s the credentials when matching a cached
609+
* connection and crashes on a NULL username/password, so pass "". */
610+
rc = SQLConnect(H->dbc, (SQLCHAR *) dbh->data_source, SQL_NTS,
611+
(SQLCHAR *) (dbh->username ? dbh->username : ""), SQL_NTS,
612+
(SQLCHAR *) (dbh->password ? dbh->password : ""), SQL_NTS);
609613
}
610614

611615
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {

0 commit comments

Comments
 (0)