updates.
[silc.git] / lib / silccore / silcpacket.c
index d05c0bd104196fd37b6217ed7b9ef27d6cfc8b4e..0791a70f590832ed7828b130dfac1457ff035e57 100644 (file)
@@ -334,6 +334,10 @@ void silc_packet_receive_process(SilcSocketConnection sock,
   int packetlen, paddedlen, mac_len = 0;
   int block_len = cipher ? silc_cipher_get_block_len(cipher) : 0;
   bool cont = TRUE;
+
+  /* Do not process for disconnected connection */
+  if (SILC_IS_DISCONNECTED(sock))
+    return;
   
   if (sock->inbuf->len < SILC_PACKET_MIN_HEADER_LEN)
     return;
@@ -344,6 +348,11 @@ void silc_packet_receive_process(SilcSocketConnection sock,
   /* Parse the packets from the data */
   while (sock->inbuf->len > 0 && cont) {
 
+    if (sock->inbuf->len < SILC_PACKET_MIN_HEADER_LEN) {
+      SILC_LOG_DEBUG(("Partial packet in queue, waiting for the rest"));
+      return;
+    }
+
     /* Decrypt first 16 bytes of the packet */
     if (!SILC_IS_INBUF_PENDING(sock) && cipher)
       silc_cipher_decrypt(cipher, sock->inbuf->data, sock->inbuf->data,