From 9c7e43b3821fa38e46f8eb50df65b7ccb0953da3 Mon Sep 17 00:00:00 2001 From: Lazizbek Ergashev Date: Tue, 27 Oct 2026 19:28:59 +0500 Subject: [PATCH] Fix GH-24736: php_odbc_connstr_is_quoted() accepts missing closing brace (#24737) * Fix GH-24736: php_odbc_connstr_is_quoted() accepts missing closing brace * Update comment for closing brace check --- NEWS | 4 ++++ ext/odbc/tests/gh24736.phpt | 20 ++++++++++++++++++++ main/php_odbc_utils.c | 9 +++++---- 3 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 ext/odbc/tests/gh24736.phpt diff --git a/NEWS b/NEWS index 464c723e6aa..6f447b572e2 100644 --- a/NEWS +++ b/NEWS @@ -92,6 +92,10 @@ PHP NEWS . Fixed bug GH-24293 (Segfault on connect with an empty password to a MariaDB PAM account). (lazerg) +- ODBC: + . Fixed bug GH-24736 (php_odbc_connstr_is_quoted() treats a value with no + closing brace as quoted). (lazerg) + - Opcache: . Fixed tracing JIT returning a wrapped integer instead of a float on integer overflow after an integer was compared with a float or diff --git a/ext/odbc/tests/gh24736.phpt b/ext/odbc/tests/gh24736.phpt new file mode 100644 index 00000000000..a96fedeb394 --- /dev/null +++ b/ext/odbc/tests/gh24736.phpt @@ -0,0 +1,20 @@ +--TEST-- +GH-24736 (Connection string value without closing brace treated as quoted) +--EXTENSIONS-- +odbc +--FILE-- + +--EXPECT-- +bool(false) +bool(false) +bool(false) +bool(true) +bool(true) +bool(true) diff --git a/main/php_odbc_utils.c b/main/php_odbc_utils.c index 162a1eb31df..7a9ce1c00ad 100644 --- a/main/php_odbc_utils.c +++ b/main/php_odbc_utils.c @@ -48,12 +48,13 @@ PHPAPI bool php_odbc_connstr_is_quoted(const char *str) if (str[i] == '}' && str[i + 1] == '}') { /* Skip over so we don't count it again */ i++; - } else if (str[i] == '}' && str[i + 1] != '\0') { - /* If not at the end, not quoted */ - return false; + } else if (str[i] == '}') { + /* Only quoted if at the end */ + return str[i + 1] == '\0'; } } - return true; + /* No closing brace */ + return false; } /**