summaryrefslogtreecommitdiff
path: root/cpp/src
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
commit5359c12c52bfed3b2920c52e18313a9b094c96ce (patch)
tree5e5ad6aab53fb2b4e9581975f81282c4c3a9c0ad /cpp/src
parenta482cc67a7764ca791084283c0076b0397f6e153 (diff)
downloadqpid-python-5359c12c52bfed3b2920c52e18313a9b094c96ce.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/qpid@707652 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/qpid/framing/Buffer.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/cpp/src/qpid/framing/Buffer.cpp b/cpp/src/qpid/framing/Buffer.cpp
index 9c089fd0f8..459aa3881b 100644
--- a/cpp/src/qpid/framing/Buffer.cpp
+++ b/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;