summaryrefslogtreecommitdiff
path: root/funcs/func_strings.c
diff options
context:
space:
mode:
authorSean Bright <sean@malleable.com>2008-10-26 20:25:08 +0000
committerSean Bright <sean@malleable.com>2008-10-26 20:25:08 +0000
commiteaf647bac21ffdf423645cf287546f5702f30a0f (patch)
tree33d3be16b80978e6056866eaf1c5f5c4e2b96209 /funcs/func_strings.c
parent0fdde26109dff999d0ca19f0c0db55baf164f2b0 (diff)
Merged revisions 152059 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r152059 | seanbright | 2008-10-26 16:23:36 -0400 (Sun, 26 Oct 2008) | 7 lines Since passing \0 as the second argument to strchr is valid (and will match the trailing \0 of a string) we need to check that first, otherwise we end up with incorrect results. Fix suggested by reporter. (closes issue #13787) Reported by: meitinger ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@152060 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'funcs/func_strings.c')
-rw-r--r--funcs/func_strings.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/funcs/func_strings.c b/funcs/func_strings.c
index b01cee9e6..2494518e3 100644
--- a/funcs/func_strings.c
+++ b/funcs/func_strings.c
@@ -773,7 +773,10 @@ static int keypadhash(struct ast_channel *chan, const char *cmd, char *data, cha
char *bufptr, *dataptr;
for (bufptr = buf, dataptr = data; bufptr < buf + buflen - 1; dataptr++) {
- if (*dataptr == '1') {
+ if (*dataptr == '\0') {
+ *bufptr++ = '\0';
+ break;
+ } else if (*dataptr == '1') {
*bufptr++ = '1';
} else if (strchr("AaBbCc2", *dataptr)) {
*bufptr++ = '2';
@@ -793,9 +796,6 @@ static int keypadhash(struct ast_channel *chan, const char *cmd, char *data, cha
*bufptr++ = '9';
} else if (*dataptr == '0') {
*bufptr++ = '0';
- } else if (*dataptr == '\0') {
- *bufptr++ = '\0';
- break;
}
}
buf[buflen - 1] = '\0';