From 0becabfd1b70382c781d836013ac5aced4c7b2af Mon Sep 17 00:00:00 2001
From: Mark Michelson <mmichelson@digium.com>
Date: Wed, 7 May 2014 17:48:55 +0000
Subject: [PATCH] Fix encoding of custom prepare extra data.

Patches:
	res_config_odbc-take2.patch by John Hardin (License #6512)
........

Merged revisions 413396 from http://svn.asterisk.org/svn/asterisk/branches/1.8


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/11@413397 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 res/res_config_odbc.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/res/res_config_odbc.c b/res/res_config_odbc.c
index 7fe7714644..eaf6deac27 100644
--- a/res/res_config_odbc.c
+++ b/res/res_config_odbc.c
@@ -137,13 +137,13 @@ static SQLHSTMT custom_prepare(struct odbc_obj *obj, void *data)
 	va_end(ap);
 
 	if (!ast_strlen_zero(cps->extra)) {
-		if (strchr(cps->extra, ';') || strchr(cps->extra, '^')) {
-			ENCODE_CHUNK(encodebuf, cps->extra);
-			SQLBindParameter(stmt, x++, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(encodebuf), 0, (void *)encodebuf, 0, NULL);
+		const char *newval = cps->extra;
+		if (strchr(newval, ';') || strchr(newval, '^')) {
+			ENCODE_CHUNK(encodebuf, newval);
+			ast_string_field_set(cps, encoding[x], encodebuf);
+			newval = cps->encoding[x];
 		} 
-		else {
-			SQLBindParameter(stmt, x++, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(cps->extra), 0, (void *)cps->extra, 0, NULL);
-		}
+		SQLBindParameter(stmt, x++, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(newval), 0, (void *)newval, 0, NULL);
 	}
 
 	return stmt;
-- 
GitLab