aboutsummaryrefslogtreecommitdiffstats
path: root/funcs
diff options
context:
space:
mode:
authorseanbright <seanbright@f38db490-d61c-443f-a65b-d21fe96a405b>2008-10-26 20:23:36 +0000
committerseanbright <seanbright@f38db490-d61c-443f-a65b-d21fe96a405b>2008-10-26 20:23:36 +0000
commit0bcf4b1f932cdbd52da2cc8ebc7734a52c4d1795 (patch)
treeb68a6b6219e0d1b37d2a087bbdf63872e85b056d /funcs
parent119738bda6ec6e81084d733d0de906d42b8ed598 (diff)
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: http://svn.digium.com/svn/asterisk/branches/1.4@152059 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'funcs')
-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 793b016b1..2b4c43c80 100644
--- a/funcs/func_strings.c
+++ b/funcs/func_strings.c
@@ -573,7 +573,10 @@ static int keypadhash(struct ast_channel *chan, char *cmd, char *data, char *buf
char *bufptr, *dataptr;
for (bufptr = buf, dataptr = data; bufptr < buf + len - 1; dataptr++) {
- if (*dataptr == '1') {
+ if (*dataptr == '\0') {
+ *bufptr++ = '\0';
+ break;
+ } else if (*dataptr == '1') {
*bufptr++ = '1';
} else if (strchr("AaBbCc2", *dataptr)) {
*bufptr++ = '2';
@@ -593,9 +596,6 @@ static int keypadhash(struct ast_channel *chan, char *cmd, char *data, char *buf
*bufptr++ = '9';
} else if (*dataptr == '0') {
*bufptr++ = '0';
- } else if (*dataptr == '\0') {
- *bufptr++ = '\0';
- break;
}
}
buf[len - 1] = '\0';