From 445d9502bf5bf80bc0c2660a725abe780df5a109 Mon Sep 17 00:00:00 2001 From: Calvin Buckley Date: Fri, 10 Jun 2022 12:53:09 -0300 Subject: [PATCH] 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. --- NEWS | 6 +++++- ext/odbc/php_odbc.c | 3 ++- ext/pdo_odbc/odbc_driver.c | 3 ++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 70fe3c9b727..10e0e919f0b 100644 --- a/NEWS +++ b/NEWS @@ -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 diff --git a/ext/odbc/php_odbc.c b/ext/odbc/php_odbc.c index d4de4ec75b7..e7eff357640 100644 --- a/ext/odbc/php_odbc.c +++ b/ext/odbc/php_odbc.c @@ -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); diff --git a/ext/pdo_odbc/odbc_driver.c b/ext/pdo_odbc/odbc_driver.c index 76b981e2c26..cb85e7d0fe5 100644 --- a/ext/pdo_odbc/odbc_driver.c +++ b/ext/pdo_odbc/odbc_driver.c @@ -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;