Bläddra i källkod

Handle messages of size 0 properly

Ian Goldberg 1 år sedan
förälder
incheckning
11e8ed8dd7
1 ändrade filer med 11 tillägg och 0 borttagningar
  1. 11 0
      Enclave/comms.cpp

+ 11 - 0
Enclave/comms.cpp

@@ -652,6 +652,17 @@ bool ecall_message(nodenum_t node_num, uint32_t message_len)
     nodest.in_msg_offset = 0;
     nodest.in_msg_plaintext_processed = 0;
     nodest.in_msg_buf = buf;
+    // Just in case message_len == 0
+    if (nodest.in_msg_offset == nodest.in_msg_size) {
+        // This was the last chunk; handle the received message
+        uint32_t plaintext_processed = nodest.in_msg_plaintext_processed;
+        uint32_t msg_size = nodest.in_msg_size;
+        nodest.in_msg_buf = NULL;
+        nodest.in_msg_size = 0;
+        nodest.in_msg_offset = 0;
+        nodest.in_msg_plaintext_processed = 0;
+        nodest.in_msg_received(nodest, buf, plaintext_processed, msg_size);
+    }
     return true;
 }