qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject svn commit: r1161119 - in /qpid/trunk/qpid/cpp/src/qpid: framing/FieldTable.cpp framing/List.cpp messaging/Message.cpp
Date Wed, 24 Aug 2011 14:27:25 GMT
Author: gsim
Date: Wed Aug 24 14:27:24 2011
New Revision: 1161119

URL: http://svn.apache.org/viewvc?rev=1161119&view=rev
Log:
QPID-3445: Added some extra checks to decode logic; consolidated exception handling for message
decode. Patch from Paul Colby.

Modified:
    qpid/trunk/qpid/cpp/src/qpid/framing/FieldTable.cpp
    qpid/trunk/qpid/cpp/src/qpid/framing/List.cpp
    qpid/trunk/qpid/cpp/src/qpid/messaging/Message.cpp

Modified: qpid/trunk/qpid/cpp/src/qpid/framing/FieldTable.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/framing/FieldTable.cpp?rev=1161119&r1=1161118&r2=1161119&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/framing/FieldTable.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/framing/FieldTable.cpp Wed Aug 24 14:27:24 2011
@@ -198,10 +198,12 @@ void FieldTable::encode(Buffer& buffer) 
 
 void FieldTable::decode(Buffer& buffer){
     clear();
+    if (buffer.available() < 4)
+        throw IllegalArgumentException(QPID_MSG("Not enough data for field table."));
     uint32_t len = buffer.getLong();
     if (len) {
         uint32_t available = buffer.available();
-        if (available < len)
+        if ((available < len) || (available < 4))
             throw IllegalArgumentException(QPID_MSG("Not enough data for field table."));
         uint32_t count = buffer.getLong();
         uint32_t leftover = available - len;

Modified: qpid/trunk/qpid/cpp/src/qpid/framing/List.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/framing/List.cpp?rev=1161119&r1=1161118&r2=1161119&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/framing/List.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/framing/List.cpp Wed Aug 24 14:27:24 2011
@@ -49,6 +49,9 @@ void List::encode(Buffer& buffer) const
 void List::decode(Buffer& buffer)
 {
     values.clear();
+    if (buffer.available() < 4)
+        throw IllegalArgumentException(QPID_MSG("Not enough data for list, expected at least
"
+                                                " 4 bytes but only " << buffer.available()
<< " available"));
     uint32_t size = buffer.getLong();
     uint32_t available = buffer.available();
     if (available < size) {
@@ -56,6 +59,9 @@ void List::decode(Buffer& buffer)
                                                 << size << " bytes but only "
<< available << " available"));
     }
     if (size) {
+        if (buffer.available() < 4)
+            throw IllegalArgumentException(QPID_MSG("Not enough data for list, expected at
least "
+                                                    " 4 bytes but only " << buffer.available()
<< " available"));
         uint32_t count = buffer.getLong();        
         for (uint32_t i = 0; i < count; i++) {
             ValuePtr value(new FieldValue);

Modified: qpid/trunk/qpid/cpp/src/qpid/messaging/Message.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/messaging/Message.cpp?rev=1161119&r1=1161118&r2=1161119&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/messaging/Message.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/messaging/Message.cpp Wed Aug 24 14:27:24 2011
@@ -21,6 +21,7 @@
 #include "qpid/messaging/Message.h"
 #include "qpid/messaging/MessageImpl.h"
 #include "qpid/amqp_0_10/Codecs.h"
+#include <qpid/Exception.h>
 #include <boost/format.hpp>
 
 namespace qpid {
@@ -115,7 +116,11 @@ template <class C> struct MessageCodec
     static void decode(const Message& message, typename C::ObjectType& object, const
std::string& encoding)
     {
         checkEncoding(message, encoding);
-        C::decode(message.getContent(), object);
+        try {
+            C::decode(message.getContent(), object);
+        } catch (const qpid::Exception &ex) {
+            throw EncodingException(ex.what());
+        }
     }
 
     static void encode(const typename C::ObjectType& map, Message& message, const
std::string& encoding)



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org


Mime
View raw message