Fixed channel MAC key setting in JOIN notify and command reply
[silc.git] / lib / silcclient / client_notify.c
index 64c041eaf11a6371551c4b4a757b64a82a96a83c..e855e41294908770b228663fc8bbee824eb79c8f 100644 (file)
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
-  Copyright (C) 1997 - 2007 Pekka Riikonen
+  Copyright (C) 1997 - 2008 Pekka Riikonen
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -298,8 +298,14 @@ SILC_FSM_STATE(silc_client_notify_invite)
 
   /* Get the channel entry */
   channel = silc_client_get_channel_by_id(client, conn, &id.u.channel_id);
-  if (!channel)
-    goto out;
+  if (!channel) {
+    /** Resolve channel */
+    SILC_FSM_CALL(silc_client_get_channel_by_id_resolve(
+                                         client, conn, &id.u.channel_id,
+                                         silc_client_notify_resolved,
+                                         notify));
+    /* NOT REACHED */
+  }
 
   /* If channel is being resolved handle notify after resolving */
   if (channel->internal.resolve_cmd_ident) {
@@ -529,7 +535,7 @@ SILC_FSM_STATE(silc_client_notify_signoff)
   if (tmp && tmp_len > 128)
     tmp[128] = '\0';
 
-  if (packet->dst_id_type == SILC_ID_CHANNEL) 
+  if (packet->dst_id_type == SILC_ID_CHANNEL)
     if (silc_id_str2id(packet->dst_id, packet->dst_id_len, SILC_ID_CHANNEL,
                       &id.u.channel_id, sizeof(id.u.channel_id)))
       channel = silc_client_get_channel_by_id(client, conn, &id.u.channel_id);
@@ -912,9 +918,7 @@ SILC_FSM_STATE(silc_client_notify_cmode_change)
     /* Get HMAC key from the old HMAC context, and update it to the new one */
     tmp = (unsigned char *)silc_hmac_get_key(channel->internal.hmac, &tmp_len);
     if (tmp) {
-      silc_hash_make(silc_hmac_get_hash(newhmac), tmp, tmp_len, hash);
-      silc_hmac_set_key(newhmac, hash,
-                       silc_hash_len(silc_hmac_get_hash(newhmac)));
+      silc_hmac_set_key(newhmac, tmp, tmp_len);
       if (channel->internal.hmac)
        silc_hmac_free(channel->internal.hmac);
       channel->internal.hmac = newhmac;