summaryrefslogtreecommitdiff
path: root/qpid
diff options
context:
space:
mode:
authorTed Ross <tross@apache.org>2008-10-24 15:15:10 +0000
committerTed Ross <tross@apache.org>2008-10-24 15:15:10 +0000
commit85372291008259c37eec140bace705805ab53dbe (patch)
tree56a1a8a146d332de13a6ea7540c78d43324a9e46 /qpid
parentc1c0020001879493aee524951eedb1d1d9c97c04 (diff)
downloadqpid-python-85372291008259c37eec140bace705805ab53dbe.tar.gz
Added truncation logic to putShortString and putMediumString in case strings too large to encode are supplied
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@707652 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid')
-rw-r--r--qpid/cpp/src/qpid/framing/Buffer.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/qpid/cpp/src/qpid/framing/Buffer.cpp b/qpid/cpp/src/qpid/framing/Buffer.cpp
index 9c089fd0f8..459aa3881b 100644
--- a/qpid/cpp/src/qpid/framing/Buffer.cpp
+++ b/qpid/cpp/src/qpid/framing/Buffer.cpp
@@ -220,14 +220,16 @@ void Buffer::putUInt<8>(uint64_t i) {
}
void Buffer::putShortString(const string& s){
- uint8_t len = s.length();
+ size_t slen = s.length();
+ uint8_t len = slen < 0x100 ? (uint8_t) slen : 0xFF;
putOctet(len);
s.copy(data + position, len);
position += len;
}
void Buffer::putMediumString(const string& s){
- uint16_t len = s.length();
+ size_t slen = s.length();
+ uint16_t len = slen < 0x10000 ? (uint16_t) slen : 0xFFFF;
putShort(len);
s.copy(data + position, len);
position += len;