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

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


The following issue has been ASSIGNED. 
====================================================================== 
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:                     assigned
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:              
====================================================================== 
Date Submitted:             2010-09-27 08:41 CDT
Last Modified:              2010-10-28 11:09 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.
====================================================================== 

---------------------------------------------------------------------- 
 (0128445) svnbot (reporter) - 2010-10-28 11:09
 https://issues.asterisk.org/view.php?id=18060#c128445 
---------------------------------------------------------------------- 
Repository: asterisk
Revision: 293158

U   branches/1.6.2/funcs/func_strings.c

------------------------------------------------------------------------
r293158 | jpeeler | 2010-10-28 11:09:41 -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=293158 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2010-10-28 11:09 svnbot         Note Added: 0128445                          
2010-10-28 11:09 svnbot         Status                   ready for review =>
assigned
2010-10-28 11:09 svnbot         Assigned To               => jpeeler         
======================================================================




More information about the asterisk-bugs mailing list