summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2010-05-28 07:51:49 +0000
committerGordon Sim <gsim@apache.org>2010-05-28 07:51:49 +0000
commitce7d0e4967027c0d73b7eb21ec7be27d8663e20d (patch)
tree02f4801f997ff29ffad142eb1ff6f941b8ce9679
parent02d8c94d844fc05e329a501cc33296380963d19b (diff)
downloadqpid-python-ce7d0e4967027c0d73b7eb21ec7be27d8663e20d.tar.gz
Patch from Ted Ross to prevent sasl_decode overflow
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@949126 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--extras/sasl/src/cyrus/saslwrapper.cpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/extras/sasl/src/cyrus/saslwrapper.cpp b/extras/sasl/src/cyrus/saslwrapper.cpp
index 0243eaa168..f8b08acfa6 100644
--- a/extras/sasl/src/cyrus/saslwrapper.cpp
+++ b/extras/sasl/src/cyrus/saslwrapper.cpp
@@ -252,14 +252,25 @@ bool ClientImpl::encode(const string& clearText, output_string& cipherText)
bool ClientImpl::decode(const string& cipherText, output_string& clearText)
{
+ const char* input = cipherText.c_str();
+ unsigned int inLen = cipherText.size();
+ unsigned int remaining = inLen;
+ const char* cursor = input;
const char* output;
unsigned int outlen;
- int result = sasl_decode(conn, cipherText.c_str(), cipherText.size(), &output, &outlen);
- if (result != SASL_OK) {
- setError("sasl_decode", result);
- return false;
+
+ clearText = string();
+ while (remaining > 0) {
+ unsigned int segmentLen = (remaining < maxBufSize) ? remaining : maxBufSize;
+ int result = sasl_decode(conn, cursor, segmentLen, &output, &outlen);
+ if (result != SASL_OK) {
+ setError("sasl_decode", result);
+ return false;
+ }
+ clearText = clearText + string(output, outlen);
+ cursor += segmentLen;
+ remaining -= segmentLen;
}
- clearText = string(output, outlen);
return true;
}