You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2010/03/12 22:15:00 UTC

svn commit: r922428 - /activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/MarshallingSupport.cpp

Author: tabish
Date: Fri Mar 12 21:15:00 2010
New Revision: 922428

URL: http://svn.apache.org/viewvc?rev=922428&view=rev
Log:
Fix for: https://issues.apache.org/activemq/browse/AMQCPP-261

Add a couple extra error checks for size overruns on Marshal

Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/MarshallingSupport.cpp

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/MarshallingSupport.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/MarshallingSupport.cpp?rev=922428&r1=922427&r2=922428&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/MarshallingSupport.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/MarshallingSupport.cpp Fri Mar 12 21:15:00 2010
@@ -63,6 +63,13 @@ void MarshallingSupport::writeString16( 
     try{
 
         std::size_t strSize = value.length();
+
+        if( strSize > (std::size_t)Short::MAX_VALUE ) {
+            throw IOException(
+                __FILE__, __LINE__,
+                "String size exceeds Short::MAX_VALUE and cannot be sent via Openwire." );
+        }
+
         dataOut.writeShort( (short)strSize );
         if( strSize > 0 ) {
             dataOut.write( (unsigned char*)value.c_str(), strSize, 0, strSize );
@@ -78,7 +85,15 @@ void MarshallingSupport::writeString32( 
     throw( decaf::io::IOException ) {
 
     try{
+
         std::size_t strSize = value.length();
+
+        if( strSize > (std::size_t)Integer::MAX_VALUE ) {
+            throw IOException(
+                __FILE__, __LINE__,
+                "String size exceeds Integer::MAX_VALUE and cannot be sent via Openwire." );
+        }
+
         dataOut.writeInt( (int)strSize );
         if( strSize > 0 ) {
             dataOut.write( (unsigned char*)value.c_str(), strSize, 0, strSize );