diff options
author | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2010-02-10 14:09:48 +0000 |
---|---|---|
committer | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2010-02-10 14:09:48 +0000 |
commit | bb1b8fd1fdc872cd457ec48c66372f25a03c8f74 (patch) | |
tree | 770c5a03453f0c45c0bf54c9fc8e944b71355772 /funcs/func_strings.c | |
parent | d42b316668ba4f5414749c4b9583b56d376e2ccd (diff) |
Merged revisions 245945 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
................
r245945 | tilghman | 2010-02-10 08:06:12 -0600 (Wed, 10 Feb 2010) | 9 lines
Merged revisions 245944 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r245944 | tilghman | 2010-02-10 07:37:13 -0600 (Wed, 10 Feb 2010) | 2 lines
Include examples of FILTER usage in extension patterns where a "." may be a risk.
........
................
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.2@245948 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'funcs/func_strings.c')
-rw-r--r-- | funcs/func_strings.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/funcs/func_strings.c b/funcs/func_strings.c index fe5b40f5d..a9effbfee 100644 --- a/funcs/func_strings.c +++ b/funcs/func_strings.c @@ -434,8 +434,9 @@ static int filter(struct ast_channel *chan, const char *cmd, char *parse, char * char *outbuf = buf, ac; char allowed[256] = ""; size_t allowedlen = 0; + int32_t bitfield[8] = { 0, }; /* 256 bits */ - AST_STANDARD_APP_ARGS(args, parse); + AST_STANDARD_RAW_ARGS(args, parse); if (!args.string) { ast_log(LOG_ERROR, "Usage: FILTER(<allowed-chars>,<string>)\n"); @@ -460,16 +461,23 @@ static int filter(struct ast_channel *chan, const char *cmd, char *parse, char * * Looks a little strange, until you realize that we can overflow * the size of a char. */ - for (ac = c1; ac != c2 && allowedlen < sizeof(allowed) - 1; ac++) - allowed[allowedlen++] = ac; - allowed[allowedlen++] = ac; + for (ac = c1; ac != c2; ac++) { + bitfield[ac / 32] |= 1 << (ac % 32); + } ast_debug(4, "c1=%d, c2=%d\n", c1, c2); /* Decrement before the loop increment */ (args.allowed)--; - } else - allowed[allowedlen++] = c1; + } else { + bitfield[c1 / 32] |= 1 << (c1 % 32); + } + } + + for (ac = 1; ac != 0; ac++) { + if (bitfield[ac / 32] & (1 << (ac % 32))) { + allowed[allowedlen++] = ac; + } } ast_debug(1, "Allowed: %s\n", allowed); |