[asterisk-bugs] [Asterisk 0016667]: [patch] func_math MATH off by one's

Asterisk Bug Tracker noreply at bugs.digium.com
Tue Feb 2 12:54:35 CST 2010


The following issue has been ASSIGNED. 
====================================================================== 
https://issues.asterisk.org/view.php?id=16667 
====================================================================== 
Reported By:                wdoekes
Assigned To:                tilghman
====================================================================== 
Project:                    Asterisk
Issue ID:                   16667
Category:                   Functions/func_math
Reproducibility:            always
Severity:                   trivial
Priority:                   normal
Status:                     assigned
Asterisk Version:           SVN 
JIRA:                       SWP-776 
Regression:                 No 
Reviewboard Link:            
SVN Branch (only for SVN checkouts, not tarball releases): N/A 
SVN Revision (number only!): 241895 
Request Review:              
====================================================================== 
Date Submitted:             2010-01-21 08:54 CST
Last Modified:              2010-02-02 12:54 CST
====================================================================== 
Summary:                    [patch] func_math MATH off by one's
Description: 
As can be seen from the diff, or the following snippet. MATH contains some
off-by-one's:

Dialplan:

exten => s,n,NoOp(${MATH(170 AND 63,i)} => 42)
exten => s,n,NoOp(${MATH(170AND63,i)} => 42 not 2)

Output:

NoOp("SIP/126680001-0000000c", "42 => 42") in new stack
NoOp("SIP/126680001-0000000c", "2 => 42 not 2") in new stack

This is because in the code, op is shifted +3 and later on +1 again (if
(op) mvalue2 = op+1)


I also removed some unnecessary '\0'-settage and fixed a comment (it's
number2's minuses we're worried about).


Regards,
Walter Doekes
OSSO B.V.

(P.S. I found the bitwise AND I was looking for ;-))
====================================================================== 

---------------------------------------------------------------------- 
 (0117542) svnbot (reporter) - 2010-02-02 12:54
 https://issues.asterisk.org/view.php?id=16667#c117542 
---------------------------------------------------------------------- 
Repository: asterisk
Revision: 244331

U   trunk/funcs/func_math.c

------------------------------------------------------------------------
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 https://issues.asterisk.org/view.php?id=16667)
 Reported by: wdoekes
 Patches: 
       astsvn-func_match-off-by-one.diff uploaded by wdoekes (license 717)

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=244331 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2010-02-02 12:54 svnbot         Checkin                                      
2010-02-02 12:54 svnbot         Note Added: 0117542                          
2010-02-02 12:54 svnbot         Status                   ready for review =>
assigned
2010-02-02 12:54 svnbot         Assigned To               => tilghman        
======================================================================




More information about the asterisk-bugs mailing list