X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=lib%2Fsilcclient%2Fclient_channel.c;h=1a4a6d5968a7dc86acd239d228369e0ce975f571;hb=386c883d8774999c6e74d7c6c37e52e4163a4cb1;hp=814dea43b6c03b942ea56fab22ddac58bbaf09fd;hpb=9a85416f729ef965606a688fffb6baa9d22927a5;p=silc.git diff --git a/lib/silcclient/client_channel.c b/lib/silcclient/client_channel.c index 814dea43..1a4a6d59 100644 --- a/lib/silcclient/client_channel.c +++ b/lib/silcclient/client_channel.c @@ -177,6 +177,16 @@ static void silc_client_channel_message_cb(SilcClient client, if (!channel) goto out; + /* If this client is not on channel, add it there since it clearly + is there. */ + if (!silc_client_on_channel(channel, clients[0])) { + SilcChannelUser chu = silc_calloc(1, sizeof(*chu)); + chu->client = clients[0]; + chu->channel = channel; + silc_hash_table_add(channel->user_list, clients[0], chu); + silc_hash_table_add(clients[0]->channels, channel, chu); + } + message = silc_channel_message_get_data(res->payload, NULL); /* Pass the message to application */ @@ -241,14 +251,16 @@ void silc_client_channel_message(SilcClient client, we will use the old key in decryption. If that fails too then we cannot do more and will drop the packet. */ if (!payload) { - if (!channel->old_channel_key) + if (!channel->old_channel_key) { goto out; + } payload = silc_channel_message_payload_parse(buffer->data, buffer->len, channel->old_channel_key, channel->old_hmac); - if (!payload) + if (!payload) { goto out; + } } } else if (channel->private_keys) { SilcChannelPrivateKey entry; @@ -384,8 +396,7 @@ void silc_client_save_channel_key(SilcClient client, key = silc_channel_key_get_key(payload, &tmp_len); cipher = silc_channel_key_get_cipher(payload, NULL); channel->key_len = tmp_len * 8; - channel->key = silc_calloc(tmp_len, sizeof(*channel->key)); - memcpy(channel->key, key, tmp_len); + channel->key = silc_memdup(key, tmp_len); if (!silc_cipher_alloc(cipher, &channel->channel_key)) { client->internal->ops->say( @@ -508,8 +519,7 @@ int silc_client_add_channel_private_key(SilcClient client, /* Save the key */ entry = silc_calloc(1, sizeof(*entry)); - entry->key = silc_calloc(keymat->enc_key_len / 8, sizeof(*entry->key)); - memcpy(entry->key, keymat->send_enc_key, keymat->enc_key_len / 8); + entry->key = silc_memdup(keymat->send_enc_key, keymat->enc_key_len / 8); entry->key_len = keymat->enc_key_len / 8; /* Allocate the cipher and set the key*/