From 5359c12c52bfed3b2920c52e18313a9b094c96ce Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Fri, 24 Oct 2008 15:15:10 +0000 Subject: 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 --- cpp/src/qpid/framing/Buffer.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'cpp/src/qpid/framing/Buffer.cpp') 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; -- cgit v1.2.1