]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
msg/async: ensure consistency between con_mode and session_security.
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Sun, 27 Jan 2019 19:28:40 +0000 (20:28 +0100)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Thu, 21 Feb 2019 20:53:28 +0000 (21:53 +0100)
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
src/msg/async/ProtocolV2.cc

index 7bec0e69fff18a795b29eae5164a3124ad8b679a..30e61934408a5fa4c22a924dbc9565ca327015ed 100644 (file)
@@ -1061,7 +1061,8 @@ uint32_t ProtocolV2::calculate_payload_size(
   AuthStreamHandler *stream_handler,
   uint32_t length)
 {
-  if (stream_handler) {
+  if (auth_meta.is_mode_secure()) {
+    ceph_assert(stream_handler != nullptr);
     return stream_handler->calculate_payload_size(length);
   } else {
     return length;
@@ -1069,17 +1070,19 @@ uint32_t ProtocolV2::calculate_payload_size(
 }
 
 void ProtocolV2::authencrypt_payload(bufferlist &payload) {
-  // using tx
-  if (session_security.tx) {
+  if (auth_meta->is_mode_secure()) {
+    // using tx
+    ceph_assert(session_security.tx);
     session_security.tx->authenticated_encrypt(payload);
-    // padding will be always present
-    ceph_assert_always(payload.length() > 0);
+    ceph_assert(payload.length() > 0);
   }
 }
 
 void ProtocolV2::authdecrypt_payload(char *payload, uint32_t &length) {
-  // using rx
-  if (session_security.rx) {
+  if (auth_meta->is_mode_secure()) {
+    ceph_assert(session_security.rx);
+    // using rx
+    ceph_assert(length > 0);
     session_security.rx->authenticated_decrypt(payload, length);
   }
 }