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: https://origsvn.digium.com/svn/asterisk/trunk@251877 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
parent
7f68a32417
commit
74be58a31f
|
@ -104,6 +104,7 @@ static int system_exec_helper(struct ast_channel *chan, const char *data, int fa
|
||||||
{
|
{
|
||||||
int res = 0;
|
int res = 0;
|
||||||
struct ast_str *buf = ast_str_thread_get(&buf_buf, 16);
|
struct ast_str *buf = ast_str_thread_get(&buf_buf, 16);
|
||||||
|
char *cbuf;
|
||||||
|
|
||||||
if (ast_strlen_zero(data)) {
|
if (ast_strlen_zero(data)) {
|
||||||
ast_log(LOG_WARNING, "System requires an argument(command)\n");
|
ast_log(LOG_WARNING, "System requires an argument(command)\n");
|
||||||
|
@ -115,7 +116,15 @@ static int system_exec_helper(struct ast_channel *chan, const char *data, int fa
|
||||||
|
|
||||||
/* Do our thing here */
|
/* Do our thing here */
|
||||||
ast_str_get_encoded_str(&buf, 0, (char *) data);
|
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)) {
|
if ((res < 0) && (errno != ECHILD)) {
|
||||||
ast_log(LOG_WARNING, "Unable to execute '%s'\n", (char *)data);
|
ast_log(LOG_WARNING, "Unable to execute '%s'\n", (char *)data);
|
||||||
|
|
Loading…
Reference in New Issue