[asterisk-commits] tilghman: branch 1.6.2 r251879 - in /branches/1.6.2: ./ apps/app_system.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Mar 11 14:27:41 CST 2010


Author: tilghman
Date: Thu Mar 11 14:27:37 2010
New Revision: 251879

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=251879
Log:
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
........

Modified:
    branches/1.6.2/   (props changed)
    branches/1.6.2/apps/app_system.c

Propchange: branches/1.6.2/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.

Modified: branches/1.6.2/apps/app_system.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.2/apps/app_system.c?view=diff&rev=251879&r1=251878&r2=251879
==============================================================================
--- branches/1.6.2/apps/app_system.c (original)
+++ branches/1.6.2/apps/app_system.c Thu Mar 11 14:27:37 2010
@@ -104,7 +104,8 @@
 {
 	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 @@
 
 	/* 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);




More information about the asterisk-commits mailing list