summaryrefslogtreecommitdiff
path: root/qpid
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2015-09-01 22:27:52 +0000
committerGordon Sim <gsim@apache.org>2015-09-01 22:27:52 +0000
commit515609c7f9ee2de53ae7aa5a29aee6ceb3ebde43 (patch)
tree92a0f815e08e1a3f0ab91a55f6e54017fc071c3a /qpid
parent85ed093ba4beae54c1622000cb7a38cb30889239 (diff)
downloadqpid-python-515609c7f9ee2de53ae7aa5a29aee6ceb3ebde43.tar.gz
QPID-6639: ensure all available data is decoded
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1700681 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid')
-rw-r--r--qpid/cpp/src/qpid/broker/amqp/Sasl.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/qpid/cpp/src/qpid/broker/amqp/Sasl.cpp b/qpid/cpp/src/qpid/broker/amqp/Sasl.cpp
index 3163e6a97a..890de40eb4 100644
--- a/qpid/cpp/src/qpid/broker/amqp/Sasl.cpp
+++ b/qpid/cpp/src/qpid/broker/amqp/Sasl.cpp
@@ -44,16 +44,20 @@ Sasl::~Sasl() {}
size_t Sasl::decode(const char* buffer, size_t size)
{
- if (state == AUTHENTICATED || state == SUCCESS_PENDING) {
- if (securityLayer.get()) return securityLayer->decode(buffer, size);
- else return connection.decode(buffer, size);
- } else if (state == INCOMPLETE && size) {
- size_t decoded = read(buffer, size);
- QPID_LOG(trace, id << " Sasl::decode(" << size << "): " << decoded);
- return decoded;
- } else {
- return 0;
+ size_t total = 0;
+ while (total < size) {
+ size_t decoded = 0;
+ if (state == AUTHENTICATED || state == SUCCESS_PENDING) {
+ if (securityLayer.get()) decoded = securityLayer->decode(buffer+total, size-total);
+ else decoded = connection.decode(buffer+total, size-total);
+ } else if (state == INCOMPLETE && size) {
+ decoded = read(buffer+total, size-total);
+ QPID_LOG(trace, id << " Sasl::decode(" << size << "): " << decoded << " (" << total << ")");
+ }
+ if (decoded) total += decoded;
+ else break;
}
+ return total;
}
size_t Sasl::encode(char* buffer, size_t size)