aboutsummaryrefslogtreecommitdiffstats
path: root/funcs/func_curl.c
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-10-06 20:52:04 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-10-06 20:52:04 +0000
commit3b1bf702011c08401b97cee1017895dfcc7ee264 (patch)
treece7af6e2837fc62eebc72d3fa67614f23e1579cf /funcs/func_curl.c
parenta4c4257ac1ae5b983a65863f0c610822ee0623f3 (diff)
Dialplan functions should not actually return 0, unless they have modified the
workspace. To signal an error (and no change to the workspace), -1 should be returned instead. (closes issue #13340) Reported by: kryptolus Patches: 20080827__bug13340__2.diff.txt uploaded by Corydon76 (license 14) git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@146799 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'funcs/func_curl.c')
-rw-r--r--funcs/func_curl.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/funcs/func_curl.c b/funcs/func_curl.c
index bc6eadee0..2c71cf7a2 100644
--- a/funcs/func_curl.c
+++ b/funcs/func_curl.c
@@ -97,6 +97,7 @@ AST_THREADSTORAGE_CUSTOM(curl_instance, curl_instance_init, curl_instance_cleanu
static int curl_internal(struct MemoryStruct *chunk, char *url, char *post)
{
+ int ret;
CURL **curl;
if (!(curl = ast_threadstorage_get(&curl_instance, sizeof(*curl))))
@@ -119,16 +120,17 @@ static int curl_internal(struct MemoryStruct *chunk, char *url, char *post)
curl_easy_setopt(*curl, CURLOPT_POSTFIELDS, post);
}
- curl_easy_perform(*curl);
+ ret = curl_easy_perform(*curl);
if (post)
curl_easy_setopt(*curl, CURLOPT_POST, 0);
- return 0;
+ return ret ? -1 : 0;
}
static int acf_curl_exec(struct ast_channel *chan, char *cmd, char *info, char *buf, size_t len)
{
+ int ret = -1;
struct ast_module_user *u;
struct MemoryStruct chunk = { NULL, 0 };
AST_DECLARE_APP_ARGS(args,
@@ -159,6 +161,7 @@ static int acf_curl_exec(struct ast_channel *chan, char *cmd, char *info, char *
ast_copy_string(buf, chunk.memory, len);
free(chunk.memory);
}
+ ret = 0;
} else {
ast_log(LOG_ERROR, "Cannot allocate curl structure\n");
}
@@ -168,7 +171,7 @@ static int acf_curl_exec(struct ast_channel *chan, char *cmd, char *info, char *
ast_module_user_remove(u);
- return 0;
+ return ret;
}
struct ast_custom_function acf_curl = {