Fix handling of single-key connection strings

A connection string may contain just a single key, but
PHP used ";" as the heuristic to detect if a string was a connection
string versus plain DSN. However, a single-key connection string
would get treated like a DSN name, i.e. "DSN=*LOCAL". This makes it
so that "=" is used, as a connection string must contain a key.

Closes GH-8748.
This commit is contained in:
Calvin Buckley 2022-06-10 12:53:09 -03:00 committed by Christoph M. Becker
parent df4dd82ea0
commit 445d9502bf
No known key found for this signature in database
GPG Key ID: D66C9593118BCCB6
3 changed files with 9 additions and 3 deletions

6
NEWS
View File

@ -10,14 +10,18 @@ PHP NEWS
- MBString:
. Fixed bug GH-8685 (pcre not ready at mbstring startup). (Remi)
- ODBC:
. Fixed handling of single-key connection strings. (Calvin Buckley)
- OpenSSL:
. Fixed bug #50293 (Several openssl functions ignore the VCWD).
(Jakub Zelenka, cmb)
. Fixed bug #81713 (NULL byte injection in several OpenSSL functions working
with certificates). (Jakub Zelenka)
- PDO ODBC:
- PDO_ODBC:
. Fixed errorInfo() result on successful PDOStatement->execute(). (Yurunsoft)
. Fixed handling of single-key connection strings. (Calvin Buckley)
09 Jun 2022, PHP 8.0.20

View File

@ -2156,7 +2156,8 @@ int odbc_sqlconnect(odbc_connection **conn, char *db, char *uid, char *pwd, int
char *ldb = 0;
int ldb_len = 0;
if (strstr((char*)db, ";")) {
/* a connection string may have = but not ; - i.e. "DSN=PHP" */
if (strstr((char*)db, "=")) {
direct = 1;
if (uid && !strstr ((char*)db, "uid") && !strstr((char*)db, "UID")) {
spprintf(&ldb, 0, "%s;UID=%s;PWD=%s", db, uid, pwd);

View File

@ -437,7 +437,8 @@ static int pdo_odbc_handle_factory(pdo_dbh_t *dbh, zval *driver_options) /* {{{
goto fail;
}
if (strchr(dbh->data_source, ';')) {
/* a connection string may have = but not ; - i.e. "DSN=PHP" */
if (strchr(dbh->data_source, '=')) {
SQLCHAR dsnbuf[1024];
SQLSMALLINT dsnbuflen;