[asterisk-bugs] [JIRA] Created: (ASTERISK-20524) AMI improperly handles lines of exactly 1025 characters

David M. Lee (JIRA) noreply at issues.asterisk.org
Fri Oct 5 12:50:27 CDT 2012


AMI improperly handles lines of exactly 1025 characters
-------------------------------------------------------

                 Key: ASTERISK-20524
                 URL: https://issues.asterisk.org/jira/browse/ASTERISK-20524
             Project: Asterisk
          Issue Type: Bug
      Security Level: None
          Components: Core/ManagerInterface
    Affects Versions: 1.8.16.0
            Reporter: David M. Lee
            Severity: Minor
         Attachments: ami-line-length.sh

I found this while working on my fix for AST-961, but didn't have a chance to really track it down.

Attached I have a really simple script I use to stimulate long-line errors in the AMI parser. If you send lines of 1024 characters or less, everything works as expected. If you send lines of 1026 characters or more, it will respond with a 'line too long' error (assuming you have [my fix for long line errors|https://reviewboard.asterisk.org/r/2142/]).

But if you send a 1025 character line exactly, AMI will read a bare newline immediately after the long line, terminating the message. This leads to an extra error response, which really confuses AMI libraries, such as [StarPy|https://github.com/asterisk-org/starpy].

{code:none}
# 1024 characters passes as expected
$ ./ami-line-length.sh 1024
== 1024 ==
Asterisk Call Manager/1.1
Response: Success
Message: Authentication accepted

Event: FullyBooted
Privilege: system,all
Status: Fully Booted

Response: Success
ActionID: 12345
Variable: foo
Value: 

# 1026 characters fails as expected
[dlee at dlee-mac asterisk]$ ./ami-line-length.sh 1026
== 1026 ==
Asterisk Call Manager/1.1
Response: Success
Message: Authentication accepted

Event: FullyBooted
Privilege: system,all
Status: Fully Booted

Response: Error
ActionID: 12345
Message: Failed to parse message: line too long

# 1025 characters has an extra error response
# And, your command gets a 'Missing action' error instead of a 'line too long' error
== 1025 ==
Asterisk Call Manager/1.1
Response: Success
Message: Authentication accepted

Event: FullyBooted
Privilege: system,all
Status: Fully Booted

Response: Error
Message: Failed to parse message: line too long

Response: Error
ActionID: 12345
Message: Missing action in request

{code}

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira



More information about the asterisk-bugs mailing list