qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject svn commit: r1700681 - /qpid/trunk/qpid/cpp/src/qpid/broker/amqp/Sasl.cpp
Date Tue, 01 Sep 2015 22:27:52 GMT
Author: gsim
Date: Tue Sep  1 22:27:52 2015
New Revision: 1700681

URL: http://svn.apache.org/r1700681
Log:
QPID-6639: ensure all available data is decoded

Modified:
    qpid/trunk/qpid/cpp/src/qpid/broker/amqp/Sasl.cpp

Modified: qpid/trunk/qpid/cpp/src/qpid/broker/amqp/Sasl.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/broker/amqp/Sasl.cpp?rev=1700681&r1=1700680&r2=1700681&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/broker/amqp/Sasl.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/broker/amqp/Sasl.cpp Tue Sep  1 22:27:52 2015
@@ -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)



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message