Skip to content

Commit c0872ea

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

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

ext/pdo_odbc/odbc_driver.c

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

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

0 commit comments

Comments
 (0)