[asterisk-bugs] [JIRA] (ASTERISK-25272) [patch]The ICONV dialplan function sometimes returns garbage
Badalian Vyacheslav (JIRA)
noreply at issues.asterisk.org
Thu Feb 11 14:42:33 CST 2016
[ https://issues.asterisk.org/jira/browse/ASTERISK-25272?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=229408#comment-229408 ]
Badalian Vyacheslav commented on ASTERISK-25272:
------------------------------------------------
All function just does not matter. Since it will always return buf [0] = '\0'. It is necessary to terminate to end of buf -- *(buf + outcount) = '\0' with checks "outcount > 0" and "(buf + outcount) < sizeof(buf)"
> [patch]The ICONV dialplan function sometimes returns garbage
> ------------------------------------------------------------
>
> Key: ASTERISK-25272
> URL: https://issues.asterisk.org/jira/browse/ASTERISK-25272
> Project: Asterisk
> Issue Type: Bug
> Security Level: None
> Components: Functions/func_iconv
> Affects Versions: 11.18.0, 13.4.0
> Environment: Debian wheezy i686
> Reporter: Etienne Lessard
> Attachments: AST-25272.patch
>
>
> 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 at default:1] NoOp("SIP/gl0ezv-00000005", "") in new stack
> -- Executing [12 at default:2] Set("SIP/gl0ezv-00000005", "MSG=abcdefghijklmnopqrstuvwxyz") in new stack
> -- Executing [12 at default:3] NoOp("SIP/gl0ezv-00000005", "abcdefghijklmnopqrstuvwxyz") in new stack
> -- Executing [12 at default:4] Set("SIP/gl0ezv-00000005", "MSG=hello") in new stack
> -- Executing [12 at 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.
--
This message was sent by Atlassian JIRA
(v6.2#6252)
More information about the asterisk-bugs
mailing list