From 528dd04ecb8375fab8da00c5bc4f71fe407ed6fb Mon Sep 17 00:00:00 2001 From: Tilghman Lesher Date: Fri, 23 Nov 2007 17:05:10 +0000 Subject: [PATCH] Use ESCAPE clause for the first parameter, not just 2nd-Nth parameters. Reported by: apsaras Patch by: tilghman (Closes issue #11353) git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@89534 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- res/res_config_odbc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/res/res_config_odbc.c b/res/res_config_odbc.c index ac3cffd16d..202f2ea56b 100644 --- a/res/res_config_odbc.c +++ b/res/res_config_odbc.c @@ -266,7 +266,8 @@ static struct ast_config *realtime_multi_odbc(const char *database, const char * *op = '\0'; newval = va_arg(aq, const char *); op = !strchr(newparam, ' ') ? " =" : ""; - snprintf(sql, sizeof(sql), "SELECT * FROM %s WHERE %s%s ?", table, newparam, op); + snprintf(sql, sizeof(sql), "SELECT * FROM %s WHERE %s%s ?%s", table, newparam, op, + strcasestr(newparam, "LIKE") ? " ESCAPE '\\'" : ""); while((newparam = va_arg(aq, const char *))) { op = !strchr(newparam, ' ') ? " =" : ""; snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), " AND %s%s ?%s", newparam, op,