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 */
we will use the old key in decryption. If that fails too then we
cannot do more and will drop the packet. */
if (!payload) {
- SILC_LOG_ERROR(("decr failed"));
if (!channel->old_channel_key) {
- SILC_LOG_ERROR(("no old key"));
goto out;
}
channel->old_channel_key,
channel->old_hmac);
if (!payload) {
- SILC_LOG_ERROR(("old decr failed"));
goto out;
}
}
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(
/* 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*/