From a739cc4c7aeff0dd3bdad2002e8576a24c39fb9a Mon Sep 17 00:00:00 2001 From: Sergejs Boidenko Date: Mon, 28 Oct 2024 10:27:00 +0200 Subject: [PATCH] ........S. [ZBX-25324] fixed FreeTDS ODBC login with special characters in the password field --- ChangeLog.d/bugfix/ZBX-25324 | 1 + src/zabbix_server/odbc/odbc.c | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 ChangeLog.d/bugfix/ZBX-25324 diff --git a/ChangeLog.d/bugfix/ZBX-25324 b/ChangeLog.d/bugfix/ZBX-25324 new file mode 100644 index 00000000000..465d8bd28d1 --- /dev/null +++ b/ChangeLog.d/bugfix/ZBX-25324 @@ -0,0 +1 @@ +........S. [ZBX-25324] fixed FreeTDS ODBC login with special characters in the password field (sboidenko) diff --git a/src/zabbix_server/odbc/odbc.c b/src/zabbix_server/odbc/odbc.c index 5da26bd3863..103d1c2fb9e 100644 --- a/src/zabbix_server/odbc/odbc.c +++ b/src/zabbix_server/odbc/odbc.c @@ -242,13 +242,13 @@ static void zbx_odbc_connection_pwd_append(char **connection_str, const char *va return; len = strlen(value); - if ('{' != *value || '}' != value[len-1]) + if ('{' != *value || ('}' != value[len-1] && !(';' == value[len-1] && '}' == value[len-2]))) { int need_replacement = 0; const char *src = value; char *dst; - dst = pwd = (char *)zbx_malloc(NULL, (len + 1) * 2); + dst = pwd = (char *)zbx_malloc(NULL, (len + 1) * 2 + 1); *dst++ = '{'; while ('\0' != *src) { @@ -269,6 +269,7 @@ static void zbx_odbc_connection_pwd_append(char **connection_str, const char *va if (0 != need_replacement) { *dst++ = '}'; + *dst++ = ';'; *dst++ = '\0'; } else -- 2.34.1