[asterisk-bugs] [Asterisk 0018060]: [patch] func_string FILTER contains an infinite loop

Asterisk Bug Tracker noreply at bugs.digium.com
Thu Oct 28 11:11:54 CDT 2010


A NOTE has been added to this issue. 
====================================================================== 
https://issues.asterisk.org/view.php?id=18060 
====================================================================== 
Reported By:                wdoekes
Assigned To:                jpeeler
====================================================================== 
Project:                    Asterisk
Issue ID:                   18060
Category:                   Functions/func_strings
Reproducibility:            always
Severity:                   trivial
Priority:                   normal
Status:                     closed
Asterisk Version:           1.6.2.13 
JIRA:                       SWP-2308 
Regression:                 No 
Reviewboard Link:            
SVN Branch (only for SVN checkouts, not tarball releases): N/A 
SVN Revision (number only!):  
Request Review:              
Resolution:                 fixed
Fixed in Version:           
====================================================================== 
Date Submitted:             2010-09-27 08:41 CDT
Last Modified:              2010-10-28 11:11 CDT
====================================================================== 
Summary:                    [patch] func_string FILTER contains an infinite loop
Description: 
Hi,

func_strings FILTER() contains an infinite loop when you're using
characters
above \x7f or invalid character escapes (e.g. \xgg).


Dialplan:

Set(var=abc "dëf)
NoOp(var = ${var})
Set(filtered=${FILTER(\x30-\xff,${var})}) ;; no wrapping
NoOp(filtered = ${filtered})
Set(filtered=${FILTER(\x30-\x10,${var})}) ;; wrapping 
NoOp(filtered = ${filtered})
Hangup()

Output:

Set("var=abc "dëf") in new stack
NoOp("var = abc "dëf") in new stack
WARNING[21708]: func_strings.c:466 filter: Range wrapping in
FILTER(\x20-\xff,abc "dëf).  This may not be what you want.
<-- Infinite loop

Expected output:

Set("var=abc "dëf") in new stack
NoOp("var = abc "dëf") in new stack
Set("filtered=abcdëf") in new stack
NoOp("filtered = abcdëf") in new stack
[2010-09-27 15:25:14] WARNING[23206]: func_strings.c:466 filter: Range
wrapping in FILTER(\x30-\x10,abc "dëf).  This may not be what you want.
Set("Local/+31852100586 at osvpi_world-1268;2", "filtered=abcdëf") in new
stack
NoOp("Local/+31852100586 at osvpi_world-1268;2", "filtered = abcdëf") in new
stack
Hangup("") in new stack



I've patched func_strings.c to add a couple of (unsigned char) casts, so
that
ac != c2 is actually false at one point. Otherwise ac loops from 0 to 255
while
c2 is negative.

I've also added a backwards incompatible change of setting c2 to c1 when a
parse error (invalid character escape) occurs. Otherwise I'd get the
aforementioned warning when using a range that ends at \xff.


Regards,
Walter Doekes
OSSO B.V.
====================================================================== 

---------------------------------------------------------------------- 
 (0128447) svnbot (reporter) - 2010-10-28 11:11
 https://issues.asterisk.org/view.php?id=18060#c128447 
---------------------------------------------------------------------- 
Repository: asterisk
Revision: 293160

_U  trunk/
U   trunk/funcs/func_strings.c

------------------------------------------------------------------------
r293160 | jpeeler | 2010-10-28 11:11:53 -0500 (Thu, 28 Oct 2010) | 25
lines

Merged revisions 293159 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.8

................
  r293159 | jpeeler | 2010-10-28 11:11:08 -0500 (Thu, 28 Oct 2010) | 18
lines
  
  Merged revisions 293158 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.6.2
  
  ........
    r293158 | jpeeler | 2010-10-28 11:09:40 -0500 (Thu, 28 Oct 2010) | 11
lines
    
    Fix infinite loop in FILTER(). 
    
    Specifically when you're using characters above \x7f or invalid
character
    escapes (e.g. \xgg).
    
    (closes issue https://issues.asterisk.org/view.php?id=18060)
    Reported by: wdoekes
    Patches: 
          issue18060_func_strings_filter_infinite_loop.patch uploaded by
wdoekes (license 717)
    Tested by: wdoekes
  ........
................

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

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

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2010-10-28 11:11 svnbot         Checkin                                      
2010-10-28 11:11 svnbot         Note Added: 0128447                          
======================================================================




More information about the asterisk-bugs mailing list