[asterisk-bugs] [JIRA] (ASTERISK-26481) FILE function grabs garbage along with read data when target line has no newline

Rusty Newton (JIRA) noreply at issues.asterisk.org
Fri Mar 24 10:39:10 CDT 2017


    [ https://issues.asterisk.org/jira/browse/ASTERISK-26481?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=236109#comment-236109 ] 

Rusty Newton commented on ASTERISK-26481:
-----------------------------------------

Interesting... if you test further and find it is resolved then let us know.

> FILE function grabs garbage along with read data when target line has no newline
> --------------------------------------------------------------------------------
>
>                 Key: ASTERISK-26481
>                 URL: https://issues.asterisk.org/jira/browse/ASTERISK-26481
>             Project: Asterisk
>          Issue Type: Bug
>      Security Level: None
>          Components: Functions/General
>    Affects Versions: 14.0.1, 14.1.0
>         Environment: Linux 4.4.0-38-generic #57-Ubuntu SMP Tue Sep 6 15:42:33 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
>            Reporter: Jonathan Harris
>              Labels: dialplan, file, len, string, variables
>         Attachments: ASTERISK-26481_workaround_fixes_only_half_the_code.patch
>
>
> *Edited by Rusty Newton*
> The description and comments were a little confusing. Here is working dialplan to reproduce the issue:
> {noformat}
> exten => 5,1,Verbose(Context: ${CONTEXT} Exten:${EXTEN})
>     same => n,Set(featurefile=/etc/asterisk/testfile.txt)
>     same => n,Set(myList=A,AB,ABC,ABCD,ABCDE,ABCDEF,ABCDEFG,ABCDEFGH)
>     same => n,While($["${SET(rawVar=${SHIFT(myList)})}" != ""])
>     same => n,Verbose(rawVar is set to ${rawVar})
>     same => n,Set(FILE(${featurefile})=${rawVar})
>     same => n,Set(fileVar=${FILE(${featurefile},0,1,l,u)})
>     same => n,Set(hexDump=${SHELL(hd ${featurefile})})
>     same => n,Verbose(Before file: ---${rawVar}--- len ${LEN(${rawVar})} after file: ---${fileVar}--- LEN ${LEN(${fileVar})} hexdump:${hexDump})
>     same => n,EndWhile()
>     same => n,Hangup()
> {noformat}
> When FILE reads the file with more than one character it grabs garbage.
> {noformat}
> newtonr-laptop*CLI> channel originate LOCAL/5 at from-internal application wait 600
>     -- Called 5 at from-internal
>     -- Executing [5 at from-internal:1] Verbose("Local/5 at from-internal-00000018;2", "Context: from-internal Exten:5") in new stack
> Context: from-internal Exten:5
>     -- Executing [5 at from-internal:2] Set("Local/5 at from-internal-00000018;2", "featurefile=/etc/asterisk/testfile.txt") in new stack
>     -- Executing [5 at from-internal:3] Set("Local/5 at from-internal-00000018;2", "myList=A,AB,ABC,ABCD,ABCDE,ABCDEF,ABCDEFG,ABCDEFGH") in new stack
>     -- Executing [5 at from-internal:4] While("Local/5 at from-internal-00000018;2", "1") in new stack
>     -- Executing [5 at from-internal:5] Verbose("Local/5 at from-internal-00000018;2", "rawVar is set to A") in new stack
> rawVar is set to A
>     -- Executing [5 at from-internal:6] Set("Local/5 at from-internal-00000018;2", "FILE(/etc/asterisk/testfile.txt)=A") in new stack
>     -- Executing [5 at from-internal:7] Set("Local/5 at from-internal-00000018;2", "fileVar=A") in new stack
>     -- Executing [5 at from-internal:8] Set("Local/5 at from-internal-00000018;2", "hexDump=00000000  41                                                |A|
>     -- 00000001
>     -- ") in new stack
>     -- Executing [5 at from-internal:9] Verbose("Local/5 at from-internal-00000018;2", "Before file: ---A--- len 1 after file: ---A--- LEN 1 hexdump:00000000  41                                                |A|
>     -- 00000001
>     -- ") in new stack
> Before file: ---A--- len 1 after file: ---A--- LEN 1 hexdump:00000000  41                                                |A|
> 00000001
>     -- Executing [5 at from-internal:10] EndWhile("Local/5 at from-internal-00000018;2", "") in new stack
>     -- Executing [5 at from-internal:4] While("Local/5 at from-internal-00000018;2", "1") in new stack
>     -- Executing [5 at from-internal:5] Verbose("Local/5 at from-internal-00000018;2", "rawVar is set to AB") in new stack
> rawVar is set to AB
>     -- Executing [5 at from-internal:6] Set("Local/5 at from-internal-00000018;2", "FILE(/etc/asterisk/testfile.txt)=AB") in new stack
>     -- Executing [5 at from-internal:7] Set("Local/5 at from-internal-00000018;2", "fileVar=ABU��") in new stack
> [Oct 27 17:18:45] ERROR[12266][C-00000019]: json.c:825 ast_json_vpack: Error building JSON from '{s: s, s: s}': Invalid UTF-8 string.
> [Oct 27 17:18:45] ERROR[12266][C-00000019]: stasis_channels.c:773 ast_channel_publish_varset: Error creating message
>     -- Executing [5 at from-internal:8] Set("Local/5 at from-internal-00000018;2", "hexDump=00000000  41 42                                             |AB|
>     -- 00000002
>     -- ") in new stack
>     -- Executing [5 at from-internal:9] Verbose("Local/5 at from-internal-00000018;2", "Before file: ---AB--- len 2 after file: ---ABU��--- LEN 6 hexdump:00000000  41 42                                             |AB|
>     -- 00000002
>     -- ") in new stack
> Before file: ---AB--- len 2 after file: ---ABU��--- LEN 6 hexdump:00000000  41 42                                             |AB|
> 00000002
>     -- Executing [5 at from-internal:10] EndWhile("Local/5 at from-internal-00000018;2", "") in new stack
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.2#6252)



More information about the asterisk-bugs mailing list