[asterisk-bugs] [JIRA] (ASTERISK-21765) FILE function's length argument counts from beginning of file rather than the offset

Rusty Newton (JIRA) noreply at issues.asterisk.org
Mon May 20 19:47:01 CDT 2013


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

Rusty Newton edited comment on ASTERISK-21765 at 5/20/13 7:45 PM:
------------------------------------------------------------------

Reproduced. Just used FILE on some test files via dialplan.

The documentation (core show function FILE) doesn't match the current behavior.

In general the examples of the length argument don't match actual behavior, but here is one example:

    ;reads from the 11th to 20th byte in the file (i.e. skip the first
    10, then read 10 bytes).
    Set(foo=${FILE(/tmp/test.txt,10,10)})
Read mode (line):

Lines like the above do not represent the behavior. In my test this would return ''

To vary on that example:

For a file with the contents "0123456789"

    using the FILE arguments ",9,9" would result in ''
    using the FILE arguments ",10,9" results in

    '
    3456789
    9
    '

The newline was included in the return value.

It's at least been this way since 1.8.4 ( a random older version I had on hand)


Confirmed. Though I'm guessing the documentation has just always been wrong and hasn't been fixed. The reading consistency issue should be a bug and I've created ASTERISK-21797 for it.

I also happen to have 1.8.15 on hand, the behavior is the same there. 
{quote}
Base on previous version Asterisk
{quote}
What older version behaved differently for you?



                
      was (Author: rnewton):
    Confirmed. Though I'm guessing the documentation has just always been wrong and hasn't been fixed. The consistency issue should be a bug.

I also happen to have 1.8.15 on hand, the behavior is the same there. 
{quote}
Base on previous version Asterisk
{quote}
What older version behaved differently for you?



                  
> FILE function's length argument counts from beginning of file rather than the offset
> ------------------------------------------------------------------------------------
>
>                 Key: ASTERISK-21765
>                 URL: https://issues.asterisk.org/jira/browse/ASTERISK-21765
>             Project: Asterisk
>          Issue Type: Bug
>      Security Level: None
>          Components: Functions/func_dialplan
>    Affects Versions: 11.2.1, 11.3.0
>         Environment: AsteriskNow64 3.0.0
> Asterisk 11.2.1 and Asterisk 11.3.0
>            Reporter: John Zhong
>
> AsteriskNow64 3.0.0 running under VMWare workstation.
> There are two issues have been found while I am testing our HiTPM with AsteriskNow64 3.0.0 integration.
> Reproduce steps:
>   1) Install netcat
>   2) Create two test files as:
>      echo 0123456789 >/tmp/0123456789.txt
>      base64 -w 0 /var/lib/asterisk/sounds/en/vm-login.ulaw > /tmp/vm-login.ulaw.b64
>   3) Run: ifconfig;nc -l 4573
>   4) Add a peer for SIP client into sip.conf
>   5) Create an extension for an AGI(agi://[the_ip_address_of_nc_listen_on]) 
>   6) Call the AGI extension
>   7) If setup is correct, the nc windows should have AGI headers
>   8) Send following commands by nc:
> {noformat}
>      GET VARIABLE FILE("/tmp/0123456789.txt,2,5")
>      and 
>      GET VARIABLE FILE("/tmp/vm-login.ulaw.b64,4080,5100")
> {noformat}
>   9) Verify the result:
> {noformat}
>      GET VARIABLE FILE("/tmp/0123456789.txt,2,5")
>      200 result=1 (234)
> {noformat}
>      Base on previous version Asterisk and current document, it should
>      return (23456), the first argument is offset and the second argument
>      should be length, but it is the 1 before the end position now. 
> [Edit by Rusty Newton - removed secondary issue as you shouldn't file two bugs in one report. Filing a new issue report.]

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.asterisk.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira



More information about the asterisk-bugs mailing list