[asterisk-commits] tilghman: branch 1.6.0 r177665 - in /branches/1.6.0: ./ apps/ include/asteris...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Feb 20 11:42:17 CST 2009
Author: tilghman
Date: Fri Feb 20 11:42:16 2009
New Revision: 177665
URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=177665
Log:
Merged revisions 177664 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
........
r177664 | tilghman | 2009-02-20 11:29:51 -0600 (Fri, 20 Feb 2009) | 8 lines
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
........
Modified:
branches/1.6.0/ (props changed)
branches/1.6.0/apps/app_system.c
branches/1.6.0/include/asterisk/app.h
branches/1.6.0/include/asterisk/strings.h
branches/1.6.0/main/app.c
Propchange: branches/1.6.0/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.
Modified: branches/1.6.0/apps/app_system.c
URL: http://svn.digium.com/svn-view/asterisk/branches/1.6.0/apps/app_system.c?view=diff&rev=177665&r1=177664&r2=177665
==============================================================================
--- branches/1.6.0/apps/app_system.c (original)
+++ branches/1.6.0/apps/app_system.c Fri Feb 20 11:42:16 2009
@@ -33,6 +33,10 @@
#include "asterisk/module.h"
#include "asterisk/app.h"
#include "asterisk/channel.h" /* autoservice */
+#include "asterisk/strings.h"
+#include "asterisk/threadstorage.h"
+
+AST_THREADSTORAGE(buf_buf);
static char *app = "System";
@@ -62,6 +66,7 @@
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");
@@ -72,7 +77,9 @@
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");
Modified: branches/1.6.0/include/asterisk/app.h
URL: http://svn.digium.com/svn-view/asterisk/branches/1.6.0/include/asterisk/app.h?view=diff&rev=177665&r1=177664&r2=177665
==============================================================================
--- branches/1.6.0/include/asterisk/app.h (original)
+++ branches/1.6.0/include/asterisk/app.h Fri Feb 20 11:42:16 2009
@@ -483,6 +483,9 @@
/*! \brief Decode a string which may contain multiple encoded control or extended ASCII characters */
int ast_get_encoded_str(const char *stream, char *result, size_t result_size);
+/*! \brief Decode a stream of encoded control or extended ASCII characters */
+int ast_str_get_encoded_str(struct ast_str **str, int maxlen, const char *stream);
+
#if defined(__cplusplus) || defined(c_plusplus)
}
#endif
Modified: branches/1.6.0/include/asterisk/strings.h
URL: http://svn.digium.com/svn-view/asterisk/branches/1.6.0/include/asterisk/strings.h?view=diff&rev=177665&r1=177664&r2=177665
==============================================================================
--- branches/1.6.0/include/asterisk/strings.h (original)
+++ branches/1.6.0/include/asterisk/strings.h Fri Feb 20 11:42:16 2009
@@ -350,6 +350,11 @@
#define DS_STATIC ((struct ast_threadstorage *)3) /* not supported yet */
char str[0]; /*!< The string buffer */
};
+
+#define ast_str_size(a) ((a)->len)
+#define ast_str_strlen(a) ((a)->used)
+#define ast_str_buffer(a) ((a)->str)
+#define ast_str_update(a) (a)->used = strlen((a)->str)
/*!
* \brief Create a malloc'ed dynamic length string
Modified: branches/1.6.0/main/app.c
URL: http://svn.digium.com/svn-view/asterisk/branches/1.6.0/main/app.c?view=diff&rev=177665&r1=177664&r2=177665
==============================================================================
--- branches/1.6.0/main/app.c (original)
+++ branches/1.6.0/main/app.c Fri Feb 20 11:42:16 2009
@@ -43,6 +43,7 @@
#include "asterisk/lock.h"
#include "asterisk/indications.h"
#include "asterisk/linkedlists.h"
+#include "asterisk/strings.h"
#define MAX_OTHER_FORMATS 10
@@ -1788,3 +1789,30 @@
return 0;
}
+int ast_str_get_encoded_str(struct ast_str **str, int maxlen, const char *stream)
+{
+ char next, *buf;
+ size_t offset = 0;
+ size_t consumed;
+
+ if (strchr(stream, '\\')) {
+ while (!ast_get_encoded_char(stream, &next, &consumed)) {
+ if (offset + 2 > ast_str_size(*str) && maxlen > -1) {
+ ast_str_make_space(str, maxlen > 0 ? maxlen : (ast_str_size(*str) + 48) * 2 - 48);
+ }
+ if (offset + 2 > ast_str_size(*str)) {
+ break;
+ }
+ buf = ast_str_buffer(*str);
+ buf[offset++] = next;
+ stream += consumed;
+ }
+ buf = ast_str_buffer(*str);
+ buf[offset++] = '\0';
+ ast_str_update(*str);
+ } else {
+ ast_str_set(str, maxlen, "%s", stream);
+ }
+ return 0;
+}
+
More information about the asterisk-commits
mailing list