diff options
author | Kenneth Anthony Giusti <kgiusti@apache.org> | 2011-02-01 17:01:59 +0000 |
---|---|---|
committer | Kenneth Anthony Giusti <kgiusti@apache.org> | 2011-02-01 17:01:59 +0000 |
commit | 395cbc7a384021281cdd4c13258258d9c0435eaf (patch) | |
tree | d714b4ef5e5cc7cabcf5f05df916f910abc80415 | |
parent | 69abdbd8bdad02feee0960986d7d7f2957644553 (diff) | |
download | qpid-python-395cbc7a384021281cdd4c13258258d9c0435eaf.tar.gz |
QPID-3030: prevent buffer overflow when writing sequences of bytes.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1066097 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | cpp/src/qpid/framing/Buffer.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/cpp/src/qpid/framing/Buffer.cpp b/cpp/src/qpid/framing/Buffer.cpp index 7506cdca7b..5a5bc0325e 100644 --- a/cpp/src/qpid/framing/Buffer.cpp +++ b/cpp/src/qpid/framing/Buffer.cpp @@ -246,6 +246,7 @@ void Buffer::putShortString(const string& s){ size_t slen = s.length(); if (slen <= std::numeric_limits<uint8_t>::max()) { uint8_t len = (uint8_t) slen; + checkAvailable(slen + 1); putOctet(len); s.copy(data + position, len); position += len; @@ -258,6 +259,7 @@ void Buffer::putMediumString(const string& s){ size_t slen = s.length(); if (slen <= std::numeric_limits<uint16_t>::max()) { uint16_t len = (uint16_t) slen; + checkAvailable(slen + 2); putShort(len); s.copy(data + position, len); position += len; @@ -268,6 +270,7 @@ void Buffer::putMediumString(const string& s){ void Buffer::putLongString(const string& s){ uint32_t len = s.length(); + checkAvailable(len + 4); putLong(len); s.copy(data + position, len); position += len; @@ -301,6 +304,7 @@ void Buffer::getBin128(uint8_t* b){ void Buffer::putRawData(const string& s){ uint32_t len = s.length(); + checkAvailable(len); s.copy(data + position, len); position += len; } @@ -312,6 +316,7 @@ void Buffer::getRawData(string& s, uint32_t len){ } void Buffer::putRawData(const uint8_t* s, size_t len){ + checkAvailable(len); memcpy(data + position, s, len); position += len; } |