Do not clear inbuf for sockets that has QoS data in inbuf.
[silc.git] / lib / silccore / silcpacket.c
index 50f6369dfc2f2a89a33bf827734de1d1c61a05b2..f6e2ea15e155124ea6450127907c8734f16b59da 100644 (file)
@@ -387,7 +387,7 @@ bool silc_packet_receive_process(SilcSocketConnection sock,
     parse_ctx->packet->type = (SilcPacketType)header[3];
     parse_ctx->packet->padlen = (SilcUInt8)header[4];
     parse_ctx->packet->sequence = sequence++;
-    parse_ctx->sock = sock;
+    parse_ctx->sock = silc_socket_dup(sock);
     parse_ctx->context = parser_context;
 
     /* Check whether this is normal or special packet */
@@ -458,9 +458,14 @@ bool silc_packet_receive_process(SilcSocketConnection sock,
     memset(tmp, 0, sizeof(tmp));
   }
 
+  /* Don't clear buffer if pending data is in the buffer */
   if (cont == FALSE && sock->inbuf->len > 0)
     return TRUE;
 
+  /* Don't clear buffer if QoS data exists in the buffer */
+  if (sock->qos && sock->qos->data_len > 0)
+    return TRUE;
+
   SILC_LOG_DEBUG(("Clearing inbound buffer"));
   silc_buffer_clear(sock->inbuf);
   return TRUE;
@@ -491,6 +496,9 @@ static bool silc_packet_check_mac(SilcHmac hmac,
     /* Compare the MAC's */
     if (memcmp(packet_mac, mac, mac_len)) {
       SILC_LOG_ERROR(("MAC failed"));
+#if 1
+      abort();
+#endif
       return FALSE;
     }