diff options
author | Gordon Sim <gsim@apache.org> | 2008-05-01 15:28:12 +0000 |
---|---|---|
committer | Gordon Sim <gsim@apache.org> | 2008-05-01 15:28:12 +0000 |
commit | 6c7fc048d974972507a2910f33a342ce5ff6013c (patch) | |
tree | ea3f1659e0368cefb5cdfe9198fdf209e240a923 /qpid/cpp/src | |
parent | d6ba1af160c2b2f3a9ca1749017c526ca6b626c7 (diff) | |
download | qpid-python-6c7fc048d974972507a2910f33a342ce5ff6013c.tar.gz |
QPID-989: fix decode of zero sized map
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@652558 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src')
-rw-r--r-- | qpid/cpp/src/qpid/framing/AMQFrame.cpp | 2 | ||||
-rw-r--r-- | qpid/cpp/src/qpid/framing/FieldTable.cpp | 28 |
2 files changed, 16 insertions, 14 deletions
diff --git a/qpid/cpp/src/qpid/framing/AMQFrame.cpp b/qpid/cpp/src/qpid/framing/AMQFrame.cpp index d861251dba..c1fc647b52 100644 --- a/qpid/cpp/src/qpid/framing/AMQFrame.cpp +++ b/qpid/cpp/src/qpid/framing/AMQFrame.cpp @@ -78,7 +78,7 @@ bool AMQFrame::decode(Buffer& buffer) uint8_t type = buffer.getOctet(); uint16_t frame_size = buffer.getShort(); if (frame_size < frameOverhead()) - throw FramingErrorException(QPID_MSG("Frame size too small")); + throw FramingErrorException(QPID_MSG("Frame size too small " << frame_size)); uint8_t reserved1 = buffer.getOctet(); uint8_t field1 = buffer.getOctet(); subchannel = field1 & 0x0f; diff --git a/qpid/cpp/src/qpid/framing/FieldTable.cpp b/qpid/cpp/src/qpid/framing/FieldTable.cpp index 1f8ffa72bc..bd20c10c37 100644 --- a/qpid/cpp/src/qpid/framing/FieldTable.cpp +++ b/qpid/cpp/src/qpid/framing/FieldTable.cpp @@ -132,19 +132,21 @@ void FieldTable::encode(Buffer& buffer) const{ void FieldTable::decode(Buffer& buffer){ uint32_t len = buffer.getLong(); - uint32_t available = buffer.available(); - uint32_t count = buffer.getLong(); - if (available < len) - throw IllegalArgumentException(QPID_MSG("Not enough data for field table.")); - uint32_t leftover = available - len; - while(buffer.available() > leftover && count--){ - std::string name; - ValuePtr value(new FieldValue); - - buffer.getShortString(name); - value->decode(buffer); - values[name] = ValuePtr(value); - } + if (len) { + uint32_t available = buffer.available(); + if (available < len) + throw IllegalArgumentException(QPID_MSG("Not enough data for field table.")); + uint32_t count = buffer.getLong(); + uint32_t leftover = available - len; + while(buffer.available() > leftover && count--){ + std::string name; + ValuePtr value(new FieldValue); + + buffer.getShortString(name); + value->decode(buffer); + values[name] = ValuePtr(value); + } + } } |