X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=lib%2Fsilcclient%2Fclient_prvmsg.c;h=88bedabea4158f8e72481fa7591307c9aceefb68;hb=386c883d8774999c6e74d7c6c37e52e4163a4cb1;hp=45b785e211b495e111670542467775917a80b081;hpb=6394d86063413bc1c473723f3ef971840195bcd3;p=silc.git diff --git a/lib/silcclient/client_prvmsg.c b/lib/silcclient/client_prvmsg.c index 45b785e2..88bedabe 100644 --- a/lib/silcclient/client_prvmsg.c +++ b/lib/silcclient/client_prvmsg.c @@ -147,7 +147,6 @@ void silc_client_private_message(SilcClient client, { SilcClientConnection conn = (SilcClientConnection)sock->user_data; SilcPrivateMessagePayload payload = NULL; - SilcIDCacheEntry id_cache = NULL; SilcClientID *remote_id = NULL; SilcClientEntry remote_client; SilcMessageFlags flags; @@ -161,14 +160,9 @@ void silc_client_private_message(SilcClient client, goto out; /* Check whether we know this client already */ - if (!silc_idcache_find_by_id_one_ext(conn->client_cache, (void *)remote_id, - NULL, NULL, - silc_hash_client_id_compare, NULL, - &id_cache) || - ((SilcClientEntry)id_cache->context)->nickname == NULL) { - - if (id_cache && id_cache->context) { - remote_client = (SilcClientEntry)id_cache->context; + remote_client = silc_client_get_client_by_id(client, conn, remote_id); + if (!remote_client || !remote_client->nickname) { + if (remote_client) { if (remote_client->status & SILC_CLIENT_STATUS_RESOLVING) { remote_client->status &= ~SILC_CLIENT_STATUS_RESOLVING; goto out; @@ -183,8 +177,6 @@ void silc_client_private_message(SilcClient client, return; } - remote_client = (SilcClientEntry)id_cache->context; - /* Parse the payload and decrypt it also if private message key is set */ payload = silc_private_message_payload_parse(packet->buffer->data, packet->buffer->len, @@ -352,8 +344,7 @@ int silc_client_add_private_message_key(SilcClient client, } /* Save the key */ - client_entry->key = silc_calloc(key_len, sizeof(*client_entry->key)); - memcpy(client_entry->key, key, key_len); + client_entry->key = silc_memdup(key, key_len); client_entry->key_len = key_len; /* Produce the key material as the protocol defines */