diff libpurple/protocols/silc/chat.c @ 21044:6b02dba5bf41

Patch from Pekka Riikone to fix various SILC issues. Fixes: #3103
author Ethan Blanton <elb@pidgin.im>
date Mon, 29 Oct 2007 00:19:53 +0000
parents ab6d2763b8d8
children 6de09629f091
line wrap: on
line diff
--- a/libpurple/protocols/silc/chat.c	Mon Oct 29 00:09:18 2007 +0000
+++ b/libpurple/protocols/silc/chat.c	Mon Oct 29 00:19:53 2007 +0000
@@ -160,15 +160,17 @@
 		unsigned char *pk;
 		SilcUInt32 pk_len;
 		pk = silc_pkcs_public_key_encode(channel->founder_key, &pk_len);
-		fingerprint = silc_hash_fingerprint(NULL, pk, pk_len);
-		babbleprint = silc_hash_babbleprint(NULL, pk, pk_len);
+		if (pk) {
+			fingerprint = silc_hash_fingerprint(NULL, pk, pk_len);
+			babbleprint = silc_hash_babbleprint(NULL, pk, pk_len);
 
-		g_string_append_printf(s, _("<br><b>Founder Key Fingerprint:</b><br>%s"), fingerprint);
-		g_string_append_printf(s, _("<br><b>Founder Key Babbleprint:</b><br>%s"), babbleprint);
+			g_string_append_printf(s, _("<br><b>Founder Key Fingerprint:</b><br>%s"), fingerprint);
+			g_string_append_printf(s, _("<br><b>Founder Key Babbleprint:</b><br>%s"), babbleprint);
 
-		silc_free(fingerprint);
-		silc_free(babbleprint);
-		silc_free(pk);
+			silc_free(fingerprint);
+			silc_free(babbleprint);
+			silc_free(pk);
+		}
 	}
 
 	buf = g_string_free(s, FALSE);
@@ -460,6 +462,8 @@
 	silc_dlist_start(channel_pubkeys);
 	while ((public_key = silc_dlist_get(channel_pubkeys))) {
 		pk = silc_pkcs_public_key_encode(public_key, &pk_len);
+		if (!pk)
+			continue;
 		fingerprint = silc_hash_fingerprint(NULL, pk + 4, pk_len - 4);
 		babbleprint = silc_hash_babbleprint(NULL, pk + 4, pk_len - 4);
 
@@ -1013,9 +1017,6 @@
 	SilcClient client = sg->client;
 	SilcClientConnection conn = sg->conn;
 	const char *channel, *passphrase, *parentch;
-#if 0
-	PurpleChat *chat;
-#endif
 
 	if (!conn)
 		return;
@@ -1071,22 +1072,6 @@
 		return;
 	}
 
-#if 0
-	/* If the channel is not on buddy list, automatically add it there. */
-	chat = purple_blist_find_chat(sg->account, channel);
-	if (!chat) {
-		data = g_hash_table_new_full(g_str_hash, g_str_equal,
-					     g_free, g_free);
-		g_hash_table_replace(data, g_strdup("channel"),
-				     g_strdup(channel));
-		if (passphrase)
-		  g_hash_table_replace(data, g_strdup("passphrase"),
-				       g_strdup(passphrase));
-		chat = purple_chat_new(sg->account, NULL, data);
-		purple_blist_add_chat(chat, NULL, NULL);
-	}
-#endif
-
 	/* XXX We should have other properties here as well:
 	   1. whether to try to authenticate to the channel
 	     1a. with default key,
@@ -1320,7 +1305,7 @@
 				ret =
 			 	silc_client_send_channel_message(client, conn,
 								 channel, key,
-								 flags, NULL,
+								 flags, sg->sha1hash,
 								 buf->data,
 								 silc_buffer_len(buf));
 			silc_mime_partial_free(list);
@@ -1334,7 +1319,8 @@
 
 	/* Send channel message */
 	ret = silc_client_send_channel_message(client, conn, channel, key,
-					       flags, NULL, (unsigned char *)msg2,
+					       flags, sg->sha1hash,
+					       (unsigned char *)msg2,
 					       strlen(msg2));
 	if (ret) {
 		serv_got_chat_in(gc, id, purple_connection_get_display_name(gc), 0, msg,