qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject svn commit: r780719 - in /qpid/trunk/qpid/cpp/src: qpid/sys/cyrus/CyrusSecurityLayer.cpp qpid/sys/cyrus/CyrusSecurityLayer.h tests/.valgrind.supp
Date Mon, 01 Jun 2009 16:47:56 GMT
Author: gsim
Date: Mon Jun  1 16:47:55 2009
New Revision: 780719

URL: http://svn.apache.org/viewvc?rev=780719&view=rev
Log:
QPID-1819: ensure that security layer implementation can cope with the case where the max
allowed input to cyrus sal routines isless than the max frame size in use.


Modified:
    qpid/trunk/qpid/cpp/src/qpid/sys/cyrus/CyrusSecurityLayer.cpp
    qpid/trunk/qpid/cpp/src/qpid/sys/cyrus/CyrusSecurityLayer.h
    qpid/trunk/qpid/cpp/src/tests/.valgrind.supp

Modified: qpid/trunk/qpid/cpp/src/qpid/sys/cyrus/CyrusSecurityLayer.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/sys/cyrus/CyrusSecurityLayer.cpp?rev=780719&r1=780718&r2=780719&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/sys/cyrus/CyrusSecurityLayer.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/sys/cyrus/CyrusSecurityLayer.cpp Mon Jun  1 16:47:55 2009
@@ -29,7 +29,8 @@
 namespace cyrus {
 
 CyrusSecurityLayer::CyrusSecurityLayer(sasl_conn_t* c, uint16_t maxFrameSize) : 
-    conn(c), decrypted(0), decryptedSize(0), encrypted(0), encryptedSize(0), codec(0), maxInputSize(0),
decodeBuffer(maxFrameSize)
+    conn(c), decrypted(0), decryptedSize(0), encrypted(0), encryptedSize(0), codec(0), maxInputSize(0),

+    decodeBuffer(maxFrameSize), encodeBuffer(maxFrameSize), encoded(0)
 {
     const void* value(0);
     int result = sasl_getprop(conn, SASL_MAXOUTBUF, &value);
@@ -70,13 +71,19 @@
     size_t processed = 0;//records how many bytes have been written to buffer
     do {
         if (!encrypted) {
-            DataBuffer encodeBuffer(maxInputSize);//make sure maxInputSize > maxFrameSize
-            size_t encoded = codec->encode(encodeBuffer.data, encodeBuffer.size);
-            if (!encoded) break;//nothing more to do
-            int result = sasl_encode(conn, encodeBuffer.data, encoded, &encrypted, &encryptedSize);
+            if (!encoded) {
+                encodeBuffer.position = 0;
+                encoded = codec->encode(encodeBuffer.data, encodeBuffer.size);
+                if (!encoded) break;//nothing more to do
+            }
+
+            size_t encryptable = std::min(encoded, maxInputSize); 
+            int result = sasl_encode(conn, encodeBuffer.data + encodeBuffer.position, encryptable,
&encrypted, &encryptedSize);
             if (result != SASL_OK) {
                 throw framing::InternalErrorException(QPID_MSG("SASL encode error: " <<
sasl_errdetail(conn)));
             }
+            encodeBuffer.position += encryptable;
+            encoded -= encryptable;
         }
         size_t remaining = size - processed;
         if (remaining < encryptedSize) {

Modified: qpid/trunk/qpid/cpp/src/qpid/sys/cyrus/CyrusSecurityLayer.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/sys/cyrus/CyrusSecurityLayer.h?rev=780719&r1=780718&r2=780719&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/sys/cyrus/CyrusSecurityLayer.h (original)
+++ qpid/trunk/qpid/cpp/src/qpid/sys/cyrus/CyrusSecurityLayer.h Mon Jun  1 16:47:55 2009
@@ -60,6 +60,8 @@
     qpid::sys::Codec* codec;
     size_t maxInputSize;
     DataBuffer decodeBuffer;
+    DataBuffer encodeBuffer;
+    size_t encoded;
 };
 }}} // namespace qpid::sys::cyrus
 

Modified: qpid/trunk/qpid/cpp/src/tests/.valgrind.supp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/.valgrind.supp?rev=780719&r1=780718&r2=780719&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/.valgrind.supp (original)
+++ qpid/trunk/qpid/cpp/src/tests/.valgrind.supp Mon Jun  1 16:47:55 2009
@@ -1,4 +1,24 @@
 {
+   Reported on FC5 and RHEL5 when md5 sasl libs are installed
+   Memcheck:Leak
+   fun:*
+   fun:_dl_map_object_from_fd
+   fun:_dl_map_object
+   fun:openaux
+   fun:_dl_catch_error
+   fun:_dl_map_object_deps
+   fun:dl_open_worker
+   fun:_dl_catch_error
+   fun:_dl_open
+   fun:dlopen_doit
+   fun:_dl_catch_error
+   fun:_dlerror_run
+   fun:dlopen@@GLIBC_2.2.5
+   fun:_sasl_get_plugin
+   fun:_sasl_load_plugins
+   fun:sasl_client_init
+}
+{
    Benign leak in CPG - patched version.
    Memcheck:Leak
    fun:*



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org


Mime
View raw message