X-Git-Url: http://git.silcnet.org/gitweb/?p=silc.git;a=blobdiff_plain;f=lib%2Fsilccore%2Fsilcpacket.c;h=26f721f56f0d34448725a4c7a1e43673702e1429;hp=f552ca6d1741aebf31648e1c694d34c302792ac3;hb=805fddcf6431e784f9f77114782a90c9d12f9cbe;hpb=e9374395ec9747bddd3ea0bfd3e5a17717e97b31 diff --git a/lib/silccore/silcpacket.c b/lib/silccore/silcpacket.c index f552ca6d..26f721f5 100644 --- a/lib/silccore/silcpacket.c +++ b/lib/silccore/silcpacket.c @@ -559,7 +559,8 @@ silc_packet_engine_start(SilcRng rng, SilcBool router, if (!engine) return NULL; - engine->contexts = silc_hash_table_alloc(0, silc_hash_ptr, NULL, NULL, NULL, + engine->contexts = silc_hash_table_alloc(NULL, 0, silc_hash_ptr, + NULL, NULL, NULL, silc_packet_engine_context_destr, engine, TRUE); if (!engine->contexts) { @@ -768,10 +769,10 @@ SilcPacketStream silc_packet_stream_create(SilcPacketEngine engine, /* If this is UDP stream, allocate UDP remote stream hash table */ if (!engine->udp_remote && silc_socket_stream_is_udp(stream, NULL)) - engine->udp_remote = silc_hash_table_alloc(0, silc_hash_string, NULL, - silc_hash_string_compare, NULL, - silc_packet_engine_hash_destr, - NULL, TRUE); + engine->udp_remote = + silc_hash_table_alloc(NULL, 0, silc_hash_string_case, NULL, + silc_hash_string_case_compare, NULL, + silc_packet_engine_hash_destr, NULL, TRUE); silc_mutex_unlock(engine->lock); @@ -1494,7 +1495,7 @@ static inline void silc_packet_send_ctr_increment(SilcPacketStream stream, SILC_LOG_HEXDUMP(("IV"), ret_iv, 8); - /* Set new nonce to counter block */ + /* Set new IV to counter block */ memcpy(iv + 4, ret_iv, 8); } else { /* Increment 64-bit packet counter */ @@ -1509,7 +1510,7 @@ static inline void silc_packet_send_ctr_increment(SilcPacketStream stream, SILC_LOG_HEXDUMP(("Counter Block"), iv, 16); } -/* Internal routine to assemble outgoing packet. Assembles and encryptes +/* Internal routine to assemble outgoing packet. Assembles and encrypts the packet. The silc_packet_stream_write needs to be called to send it after this returns TRUE. */ @@ -1618,6 +1619,12 @@ static inline SilcBool silc_packet_send_raw(SilcPacketStream stream, silc_mutex_lock(stream->lock); + if (silc_unlikely(stream->destroyed)) { + SILC_LOG_DEBUG(("Stream %p is destroyed, cannot send packet", stream)); + silc_mutex_unlock(stream->lock); + return FALSE; + } + /* Get packet pointer from the outgoing buffer */ if (silc_unlikely(!silc_packet_send_prepare(stream, truelen + padlen + ivlen + psnlen, hmac, &packet))) {