[asterisk-bugs] [JIRA] (ASTERISK-26481) FILE function grabs garbage along with read data when target line has no newline
Asterisk Team (JIRA)
noreply at issues.asterisk.org
Thu Dec 12 05:40:35 CST 2019
[ https://issues.asterisk.org/jira/browse/ASTERISK-26481?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Asterisk Team updated ASTERISK-26481:
-------------------------------------
Target Release Version/s: 13.30.0
> 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, 17.0.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
> and also
> Ubuntu 19.10 (GNU/Linux 5.3.0-19-generic x86_64)
> Reporter: Jonathan Harris
> Labels: dialplan, file, len, patch, string, variables
> Target Release: 13.30.0
>
> Attachments: ASTERISK-26481_workaround_fixes_only_half_the_code.patch, filereader_code.txt, filereader_output.txt
>
>
> *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