ActiveMQTextMessage::getText() causes an index out of bounds assertion failure 
if trying to read a 0 length text message
------------------------------------------------------------------------------------------------------------------------

                 Key: AMQCPP-141
                 URL: https://issues.apache.org/activemq/browse/AMQCPP-141
             Project: ActiveMQ C++ Client
          Issue Type: Bug
          Components: Openwire
    Affects Versions: 2.1
         Environment: Windows XP, Compiled under Visual Studio 2005, Active MQ 
server 4.1.1, Active MQ java client library 4.1.1
            Reporter: Rick Hobbs
            Assignee: Nathan Mittler
         Attachments: ActiveMQTextMessage.diff

If a client (in this case a java client) sends a TextMessage with an empty 
string, a C++ based client will fail when calling getText() on the message.

The reason for this being that a test is done against the length of the content 
of the underlying message as follows:

 if( getContent().size() < 4 ) (line 49 of 
main/activemq/connector/openwire/commands/ActiveMQTextMessage.cpp).

If this test fails it is assumed that the string is 0 length. However, as the 
length of the string is written as an 4 byte int at the begining of the content 
stream this test never fails. This then causes an exception on line:

return std::string( (const char*)&getContent()[4], getContent().size()-4 );

As the "getContent()[4]" will cause an index out of bounds assertion if the 
string is 0 length.

The suggested fix would be to change the test on line 49 to:

 if( getContent().size() <= 4 ) 

A diff file is included.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to