From 41257c52f2ece3e9fb15f738943e839cc241b1fc Mon Sep 17 00:00:00 2001 From: Calvin Buckley Date: Fri, 10 Jun 2022 12:53:09 -0300 Subject: [PATCH] A connection string may contain just a single key 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. --- ext/odbc/php_odbc.c | 3 ++- ext/pdo_odbc/odbc_driver.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ext/odbc/php_odbc.c b/ext/odbc/php_odbc.c index b829ff2ae51f2..0aae07f33af89 100644 --- a/ext/odbc/php_odbc.c +++ b/ext/odbc/php_odbc.c @@ -2170,7 +2170,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; /* Force UID and PWD to be set in the DSN */ bool is_uid_set = uid && *uid diff --git a/ext/pdo_odbc/odbc_driver.c b/ext/pdo_odbc/odbc_driver.c index b9ece6d28f205..308cf7e10c94d 100644 --- a/ext/pdo_odbc/odbc_driver.c +++ b/ext/pdo_odbc/odbc_driver.c @@ -480,7 +480,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;