From 2b32b45889599318c11212ee306052b9a9f8af19 Mon Sep 17 00:00:00 2001 From: Tilghman Lesher Date: Mon, 2 May 2011 19:04:36 +0000 Subject: [PATCH] More possible crashes based upon invalid inputs. (closes issue #18161) Reported by: wdoekes Patches: 20110301__issue18161.diff.txt uploaded by tilghman (license 14) Tested by: wdoekes git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.2@316093 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- funcs/func_curl.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/funcs/func_curl.c b/funcs/func_curl.c index 9d6a0c8460..4a045a92d7 100644 --- a/funcs/func_curl.c +++ b/funcs/func_curl.c @@ -409,7 +409,11 @@ static int acf_curl_exec(struct ast_channel *chan, const char *cmd, char *info, AST_LIST_HEAD(global_curl_info, curl_settings) *list = NULL; *buf = '\0'; - + + if (!str) { + return -1; + } + if (ast_strlen_zero(info)) { ast_log(LOG_WARNING, "CURL requires an argument (URL)\n"); ast_free(str); @@ -479,13 +483,12 @@ static int acf_curl_exec(struct ast_channel *chan, const char *cmd, char *info, int rowcount = 0; while (fields && values && (piece = strsep(&remainder, "&"))) { char *name = strsep(&piece, "="); - if (!piece) { - piece = ""; + if (piece) { + ast_uri_decode(piece); } - ast_uri_decode(piece); ast_uri_decode(name); ast_str_append(&fields, 0, "%s%s", rowcount ? "," : "", name); - ast_str_append(&values, 0, "%s%s", rowcount ? "," : "", piece); + ast_str_append(&values, 0, "%s%s", rowcount ? "," : "", S_OR(piece, "")); rowcount++; } pbx_builtin_setvar_helper(chan, "~ODBCFIELDS~", ast_str_buffer(fields)); -- 2.47.2