aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2010-03-11 20:27:37 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2010-03-11 20:27:37 +0000
commit83705e6288818604c052227265a58b0f3628008b (patch)
treef2707fc89fdd6d3e6553e59482d17769dee5e5ec /apps
parentc2fd8dc43e83291cef37f3bb7a22b1fa4f425f83 (diff)
Merged revisions 251877 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk ........ r251877 | tilghman | 2010-03-11 14:25:02 -0600 (Thu, 11 Mar 2010) | 8 lines If the argument to the system application is quoted, ensure we remove the quotes before trying to execute. (closes issue #16842) Reported by: ip-rob Patches: 20100310__issue16842.diff.txt uploaded by tilghman (license 14) Tested by: ip-rob ........ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.2@251879 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps')
-rw-r--r--apps/app_system.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/apps/app_system.c b/apps/app_system.c
index e06a9cb5d..e0951bae0 100644
--- a/apps/app_system.c
+++ b/apps/app_system.c
@@ -104,7 +104,8 @@ static int system_exec_helper(struct ast_channel *chan, void *data, int failmode
{
int res = 0;
struct ast_str *buf = ast_str_thread_get(&buf_buf, 16);
-
+ char *cbuf;
+
if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "System requires an argument(command)\n");
pbx_builtin_setvar_helper(chan, chanvar, "FAILURE");
@@ -115,7 +116,15 @@ static int system_exec_helper(struct ast_channel *chan, void *data, int failmode
/* Do our thing here */
ast_str_get_encoded_str(&buf, 0, (char *) data);
- res = ast_safe_system(ast_str_buffer(buf));
+ cbuf = ast_str_buffer(buf);
+
+ if (strchr("\"'", cbuf[0]) && cbuf[ast_str_strlen(buf) - 1] == cbuf[0]) {
+ cbuf[ast_str_strlen(buf) - 1] = '\0';
+ cbuf++;
+ ast_log(LOG_NOTICE, "It is not necessary to quote the argument to the System application.\n");
+ }
+
+ res = ast_safe_system(cbuf);
if ((res < 0) && (errno != ECHILD)) {
ast_log(LOG_WARNING, "Unable to execute '%s'\n", (char *)data);