activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rick Hobbs (JIRA)" <j...@apache.org>
Subject [jira] Created: (AMQCPP-141) ActiveMQTextMessage::getText() causes an index out of bounds assertion failure if trying to read a 0 length text message
Date Wed, 22 Aug 2007 14:23:22 GMT
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.


Mime
View raw message