diff options
author | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-02-20 17:29:51 +0000 |
---|---|---|
committer | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-02-20 17:29:51 +0000 |
commit | 8d625b91bc7babbe0d41f5d7c17e3fdf82654ae8 (patch) | |
tree | cd8bc2e8e9d0899907c9a99bfcc39b5322db5b66 /apps/app_system.c | |
parent | 37b7b1ad8fe5c218f9ad254b4ef614dd7d18322f (diff) |
Allow semicolons to be escaped, when passing arguments to the System command.
(closes issue #14231)
Reported by: jcovert
Patches:
20090113__bug14231__2.diff.txt uploaded by Corydon76 (license 14)
corrected_20090113__bug14231__2.diff.txt uploaded by jcovert (license 551)
Tested by: jcovert
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@177664 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_system.c')
-rw-r--r-- | apps/app_system.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/apps/app_system.c b/apps/app_system.c index 688a649da..e06a9cb5d 100644 --- a/apps/app_system.c +++ b/apps/app_system.c @@ -33,6 +33,8 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/module.h" #include "asterisk/app.h" #include "asterisk/channel.h" /* autoservice */ +#include "asterisk/strings.h" +#include "asterisk/threadstorage.h" /*** DOCUMENTATION <application name="System" language="en_US"> @@ -90,6 +92,8 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") ***/ +AST_THREADSTORAGE(buf_buf); + static char *app = "System"; static char *app2 = "TrySystem"; @@ -99,6 +103,7 @@ static char *chanvar = "SYSTEMSTATUS"; 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); if (ast_strlen_zero(data)) { ast_log(LOG_WARNING, "System requires an argument(command)\n"); @@ -109,7 +114,9 @@ static int system_exec_helper(struct ast_channel *chan, void *data, int failmode ast_autoservice_start(chan); /* Do our thing here */ - res = ast_safe_system((char *)data); + ast_str_get_encoded_str(&buf, 0, (char *) data); + res = ast_safe_system(ast_str_buffer(buf)); + if ((res < 0) && (errno != ECHILD)) { ast_log(LOG_WARNING, "Unable to execute '%s'\n", (char *)data); pbx_builtin_setvar_helper(chan, chanvar, "FAILURE"); |