Merged revisions 244331 via svnmerge from

https://origsvn.digium.com/svn/asterisk/trunk

........
  r244331 | tilghman | 2010-02-02 12:54:33 -0600 (Tue, 02 Feb 2010) | 9 lines
  
  Correct some off-by-one errors, especially when expressions don't contain expected spaces.
  
  Also include the tests provided by the reporter, as regression tests.
  
  (closes issue #16667)
   Reported by: wdoekes
   Patches: 
         astsvn-func_match-off-by-one.diff uploaded by wdoekes (license 717)
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.0@244332 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Tilghman Lesher
2010-02-02 18:59:20 +00:00
parent c7a5783716
commit 3338bc9cb7

View File

@@ -114,47 +114,47 @@ static int math(struct ast_channel *chan, const char *cmd, char *parse,
*op = '\0'; *op = '\0';
} else if ((op = strstr(mvalue1, "AND"))) { } else if ((op = strstr(mvalue1, "AND"))) {
iaction = BITWISEANDFUNCTION; iaction = BITWISEANDFUNCTION;
op += 3;
*op = '\0'; *op = '\0';
op += 2;
} else if ((op = strstr(mvalue1, "XOR"))) { } else if ((op = strstr(mvalue1, "XOR"))) {
iaction = BITWISEXORFUNCTION; iaction = BITWISEXORFUNCTION;
op += 3;
*op = '\0'; *op = '\0';
op += 2;
} else if ((op = strstr(mvalue1, "OR"))) { } else if ((op = strstr(mvalue1, "OR"))) {
iaction = BITWISEORFUNCTION; iaction = BITWISEORFUNCTION;
op += 2;
*op = '\0'; *op = '\0';
++op;
} else if ((op = strchr(mvalue1, '>'))) { } else if ((op = strchr(mvalue1, '>'))) {
iaction = GTFUNCTION; iaction = GTFUNCTION;
*op = '\0'; *op = '\0';
if (*(op + 1) == '=') { if (*(op + 1) == '=') {
*++op = '\0';
iaction = GTEFUNCTION; iaction = GTEFUNCTION;
++op;
} else if (*(op + 1) == '>') { } else if (*(op + 1) == '>') {
*++op = '\0';
iaction = SHRIGHTFUNCTION; iaction = SHRIGHTFUNCTION;
++op;
} }
} else if ((op = strchr(mvalue1, '<'))) { } else if ((op = strchr(mvalue1, '<'))) {
iaction = LTFUNCTION; iaction = LTFUNCTION;
*op = '\0'; *op = '\0';
if (*(op + 1) == '=') { if (*(op + 1) == '=') {
*++op = '\0';
iaction = LTEFUNCTION; iaction = LTEFUNCTION;
++op;
} else if (*(op + 1) == '<') { } else if (*(op + 1) == '<') {
*++op = '\0';
iaction = SHLEFTFUNCTION; iaction = SHLEFTFUNCTION;
++op;
} }
} else if ((op = strchr(mvalue1, '='))) { } else if ((op = strchr(mvalue1, '='))) {
*op = '\0'; *op = '\0';
if (*(op + 1) == '=') { if (*(op + 1) == '=') {
*++op = '\0';
iaction = EQFUNCTION; iaction = EQFUNCTION;
++op;
} else } else
op = NULL; op = NULL;
} else if ((op = strchr(mvalue1, '+'))) { } else if ((op = strchr(mvalue1, '+'))) {
iaction = ADDFUNCTION; iaction = ADDFUNCTION;
*op = '\0'; *op = '\0';
} else if ((op = strchr(mvalue1, '-'))) { /* subtraction MUST always be last, in case we have a negative first number */ } else if ((op = strchr(mvalue1, '-'))) { /* subtraction MUST always be last, in case we have a negative second number */
iaction = SUBTRACTFUNCTION; iaction = SUBTRACTFUNCTION;
*op = '\0'; *op = '\0';
} }