summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/framing/List.cpp
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2011-08-24 14:27:24 +0000
committerGordon Sim <gsim@apache.org>2011-08-24 14:27:24 +0000
commitbbc4fc15a0cd69bb868ee97e1f2aa90c15796eab (patch)
treedd935fa1a7be54db242d7b9c21cb9659796b6441 /cpp/src/qpid/framing/List.cpp
parentb37021d7808766e4529dd14830be0309c0dfa473 (diff)
downloadqpid-python-bbc4fc15a0cd69bb868ee97e1f2aa90c15796eab.tar.gz
QPID-3445: Added some extra checks to decode logic; consolidated exception handling for message decode. Patch from Paul Colby.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1161119 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/framing/List.cpp')
-rw-r--r--cpp/src/qpid/framing/List.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/cpp/src/qpid/framing/List.cpp b/cpp/src/qpid/framing/List.cpp
index 963ebc206b..d7ea172bac 100644
--- a/cpp/src/qpid/framing/List.cpp
+++ b/cpp/src/qpid/framing/List.cpp
@@ -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);