X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=lib%2Fsilccore%2Fsilcpacket.c;h=68cb566c884fe99a6e3857416d97698ce84eff02;hb=83c73dffa89141bc59e62436abb63b3d3efca6bb;hp=7674a0302fa836b78a5bf1a4b750145db5491043;hpb=e2890b9b6f74ba4ab2f4ac67658f5c0fea4380b3;p=silc.git diff --git a/lib/silccore/silcpacket.c b/lib/silccore/silcpacket.c index 7674a030..68cb566c 100644 --- a/lib/silccore/silcpacket.c +++ b/lib/silccore/silcpacket.c @@ -332,7 +332,8 @@ void silc_packet_receive_process(SilcSocketConnection sock, SilcPacketParserContext *parse_ctx; int packetlen, paddedlen, mac_len = 0; int block_len = cipher ? silc_cipher_get_block_len(cipher) : 0; - + bool cont = TRUE; + if (sock->inbuf->len < SILC_PACKET_MIN_HEADER_LEN) return; @@ -340,7 +341,7 @@ void silc_packet_receive_process(SilcSocketConnection sock, mac_len = silc_hmac_len(hmac); /* Parse the packets from the data */ - while (sock->inbuf->len > 0) { + while (sock->inbuf->len > 0 && cont) { /* Decrypt first 16 bytes of the packet */ if (!SILC_IS_INBUF_PENDING(sock) && cipher) @@ -404,15 +405,17 @@ void silc_packet_receive_process(SilcSocketConnection sock, silc_packet_decrypt(cipher, hmac, parse_ctx->packet->sequence, parse_ctx->packet->buffer, parse_ctx->normal); - /* Call the parser */ - if (parser) - (*parser)(parse_ctx, parser_context); - /* Pull the packet from inbuf thus we'll get the next one in the inbuf. */ silc_buffer_pull(sock->inbuf, paddedlen + mac_len); + + /* Call the parser */ + cont = (*parser)(parse_ctx, parser_context); } + if (cont == FALSE && sock->inbuf->len > 0) + return; + SILC_LOG_DEBUG(("Clearing inbound buffer")); silc_buffer_clear(sock->inbuf); }