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 /main/app.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 'main/app.c')
-rw-r--r-- | main/app.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/main/app.c b/main/app.c index 83939c55b..cf48b2f1f 100644 --- a/main/app.c +++ b/main/app.c @@ -1846,6 +1846,33 @@ char *ast_get_encoded_str(const char *stream, char *result, size_t result_size) return result; } +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; +} + void ast_close_fds_above_n(int n) { #ifdef HAVE_CLOSEFROM |