[Home]

Summary:ASTERISK-25272: [patch]The ICONV dialplan function sometimes returns garbage
Reporter:Etienne Lessard (hexanol)Labels:
Date Opened:2015-07-22 06:54:56Date Closed:2016-02-11 15:30:35.000-0600
Priority:MajorRegression?No
Status:Closed/CompleteComponents:Functions/func_iconv
Versions:11.18.0 13.4.0 Frequency of
Occurrence
Constant
Related
Issues:
Environment:Debian wheezy i686Attachments:( 0) AST-25272.patch
Description:Given I have the following extension:
{noformat}
exten = 12,1,NoOp()
same  =   n,Set(MSG=abcdefghijklmnopqrstuvwxyz)
same  =   n,NoOp(${ICONV(ASCII,ASCII,${MSG})})
same  =   n,Set(MSG=hello)
same  =   n,NoOp(${ICONV(ASCII,ASCII,${MSG})})
same  =   n,Hangup()
{noformat}
When I call this extension
Then I see in the Asterisk CLI:
{noformat}
-- Executing [12@default:1] NoOp("SIP/gl0ezv-00000005", "") in new stack
-- Executing [12@default:2] Set("SIP/gl0ezv-00000005", "MSG=abcdefghijklmnopqrstuvwxyz") in new stack
-- Executing [12@default:3] NoOp("SIP/gl0ezv-00000005", "abcdefghijklmnopqrstuvwxyz") in new stack
-- Executing [12@default:4] Set("SIP/gl0ezv-00000005", "MSG=hello") in new stack
-- Executing [12@default:5] NoOp("SIP/gl0ezv-00000005", "hellofghijklmnopqrstuvwxyz") in new stack
{noformat}

Expected: the second call to ICONV (at priority 5) returns "hello" instead of "hellofghijklmnopqrstuvwxyz".

There's other way to trigger the bug, but this dialplan is the easiest way I have found.

I've taken a look at func_iconv.c, and we can see that a null character is not appended at the end of the output string, and since the output string is not previously filled with null character, this bugs shows up.

I've attached a patch that I tested against the following scenarios:
* original test described in this issue
* converting "Valérie" from UTF-8 to ASCII//IGNORE
* converting "Valérie" from UTF-8 to ASCII

Thank you.
Comments:By: Asterisk Team (asteriskteam) 2015-07-22 06:54:58.566-0500

Thanks for creating a report! The issue has entered the triage process. That means the issue will wait in this status until a Bug Marshal has an opportunity to review the issue. Once the issue has been reviewed you will receive comments regarding the next steps towards resolution.

A good first step is for you to review the [Asterisk Issue Guidelines|https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines] if you haven't already. The guidelines detail what is expected from an Asterisk issue report.

Then, if you are submitting a patch, please review the [Patch Contribution Process|https://wiki.asterisk.org/wiki/display/AST/Patch+Contribution+Process].

By: Jesper (ib2) 2016-01-07 08:35:06.511-0600

ICONV is useless without this patch
also exist in 11.20.0