changeset 15246:c9b56198e8db

[gaim-migrate @ 18036] * Convert or validate the chat room name in chat room invites as UTF8 * Bail out if the ICBM cookie doesn't match the rendezvous ICBM cookie committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Thu, 21 Dec 2006 08:58:55 +0000
parents d5e7690a9b06
children 8948ebd0c4b1
files libgaim/protocols/oscar/family_chat.c libgaim/protocols/oscar/family_icbm.c libgaim/protocols/oscar/oscar.c libgaim/protocols/oscar/oscar.h
diffstat 4 files changed, 34 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/libgaim/protocols/oscar/family_chat.c	Thu Dec 21 08:14:05 2006 +0000
+++ b/libgaim/protocols/oscar/family_chat.c	Thu Dec 21 08:58:55 2006 +0000
@@ -116,14 +116,12 @@
 int
 aim_chat_readroominfo(ByteStream *bs, struct aim_chat_roominfo *outinfo)
 {
-	int namelen;
-
 	if (!bs || !outinfo)
 		return 0;
 
 	outinfo->exchange = byte_stream_get16(bs);
-	namelen = byte_stream_get8(bs);
-	outinfo->name = byte_stream_getstr(bs, namelen);
+	outinfo->namelen = byte_stream_get8(bs);
+	outinfo->name = byte_stream_getraw(bs, outinfo->namelen);
 	outinfo->instance = byte_stream_get16(bs);
 
 	return 0;
--- a/libgaim/protocols/oscar/family_icbm.c	Thu Dec 21 08:14:05 2006 +0000
+++ b/libgaim/protocols/oscar/family_icbm.c	Thu Dec 21 08:58:55 2006 +0000
@@ -1915,7 +1915,12 @@
 	 */
 	cookie2 = byte_stream_getraw(&bbs, 8);
 	if (memcmp(cookie, cookie2, 8) != 0)
-		gaim_debug_misc("oscar", "rend: warning cookies don't match!\n");
+	{
+		gaim_debug_warning("oscar",
+				"Cookies don't match in rendezvous ICBM, bailing out.\n");
+		free(cookie2);
+		return 1;
+	}
 	memcpy(args.cookie, cookie2, 8);
 	free(cookie2);
 
--- a/libgaim/protocols/oscar/oscar.c	Thu Dec 21 08:14:05 2006 +0000
+++ b/libgaim/protocols/oscar/oscar.c	Thu Dec 21 08:58:55 2006 +0000
@@ -845,10 +845,13 @@
 		return NULL;
 
 	x = strchr(name, '-');
-
-	if (!x) return NULL;
-	x = strchr(++x, '-');
-	if (!x) return NULL;
+	if (!x)
+		return NULL;
+
+	x = strchr(x + 1, '-');
+	if (!x)
+		return NULL;
+
 	tmp = g_strdup(++x);
 
 	for (i = 0, j = 0; x[i]; i++) {
@@ -857,7 +860,8 @@
 			tmp[j++] = x[i];
 			continue;
 		}
-		strncpy(hex, x + ++i, 2); hex[2] = 0;
+		strncpy(hex, x + ++i, 2);
+		hex[2] = 0;
 		i++;
 		tmp[j++] = strtol(hex, NULL, 16);
 	}
@@ -2046,27 +2050,36 @@
 
 	if (args->type & OSCAR_CAPABILITY_CHAT)
 	{
-		char *name;
+		char *encoding, *utf8name, *tmp;
 		GHashTable *components;
 
 		if (!args->info.chat.roominfo.name || !args->info.chat.roominfo.exchange) {
 			g_free(message);
 			return 1;
 		}
+		encoding = args->encoding ? oscar_encoding_extract(args->encoding) : NULL;
+		utf8name = oscar_encoding_to_utf8(encoding,
+				args->info.chat.roominfo.name,
+				args->info.chat.roominfo.namelen);
+		g_free(encoding);
+
+		tmp = extract_name(utf8name);
+		if (tmp != NULL)
+		{
+			g_free(utf8name);
+			utf8name = tmp;
+		}
+
 		components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
 				g_free);
-		name = extract_name(args->info.chat.roominfo.name);
-		g_hash_table_replace(components, g_strdup("room"),
-				g_strdup(name ? name : args->info.chat.roominfo.name));
+		g_hash_table_replace(components, g_strdup("room"), utf8name);
 		g_hash_table_replace(components, g_strdup("exchange"),
 				g_strdup_printf("%d", args->info.chat.roominfo.exchange));
 		serv_got_chat_invite(gc,
-				     name ? name : args->info.chat.roominfo.name,
+				     utf8name,
 				     userinfo->sn,
 				     message,
 				     components);
-		if (name)
-			g_free(name);
 	}
 
 	else if ((args->type & OSCAR_CAPABILITY_SENDFILE) ||
--- a/libgaim/protocols/oscar/oscar.h	Thu Dec 21 08:14:05 2006 +0000
+++ b/libgaim/protocols/oscar/oscar.h	Thu Dec 21 08:58:55 2006 +0000
@@ -698,6 +698,7 @@
 {
 	guint16 exchange;
 	char *name;
+	guint8 namelen;
 	guint16 instance;
 };