soc.2010.icq-tlc: 2da35989: Fixed (I hope) #12284.

ivan.komarov at soc.pidgin.im ivan.komarov at soc.pidgin.im
Sat Jul 24 14:35:52 EDT 2010


----------------------------------------------------------------------
Revision: 2da3598932dda1585bdbc1dfd2cb7f35a8bb924d
Parent:   e59fba6c765beb6e086cb29b250db509e4bb1474
Author:   ivan.komarov at soc.pidgin.im
Date:     07/24/10 14:14:29
Branch:   im.pidgin.soc.2010.icq-tlc
URL: http://d.pidgin.im/viewmtn/revision/info/2da3598932dda1585bdbc1dfd2cb7f35a8bb924d

Changelog: 

Fixed (I hope) #12284.

incomingim_ch2_icqserverrelay() was doing something it wasn't supposed to.
I suppose the packet format was reverse-engineered wrongly eons ago.
The correct packet format can be found at http://iserverd.khstu.ru/oscar/message.html
(and also in every open-source OSCAR client I could get my hands on).

The funny thing is that before #12284 showed up everything worked
right due to another bug. I'm too lazy to type out all the details,
so I'll just include a reference to my conversation with Mark Doliner:

http://www.pidgin.im/nopaste/102

Changes against parent e59fba6c765beb6e086cb29b250db509e4bb1474

  patched  libpurple/protocols/oscar/family_icbm.c
  patched  libpurple/protocols/oscar/oscar.c
  patched  libpurple/protocols/oscar/oscar.h

-------------- next part --------------
============================================================
--- libpurple/protocols/oscar/oscar.c	9a56792852eb9f2cac80409b5eefc3b2e5435fcd
+++ libpurple/protocols/oscar/oscar.c	d247a5a892353b94a722ab99f5975937e68e3644
@@ -1812,17 +1812,17 @@ incomingim_chan2(OscarData *od, FlapConn
 
 		if (args->info.rtfmsg.msgtype == 1)
 		{
-			if (args->info.rtfmsg.rtfmsg != NULL)
+			if (args->info.rtfmsg.msg != NULL)
 			{
 				char *rtfmsg = NULL;
 				if (args->encoding != NULL) {
 					char *encoding = oscar_encoding_extract(args->encoding);
 					rtfmsg = oscar_encoding_to_utf8(account, encoding,
-							args->info.rtfmsg.rtfmsg, strlen(args->info.rtfmsg.rtfmsg));
+							args->info.rtfmsg.msg, strlen(args->info.rtfmsg.msg));
 					g_free(encoding);
 				} else {
-					if (g_utf8_validate(args->info.rtfmsg.rtfmsg, strlen(args->info.rtfmsg.rtfmsg), NULL))
-						rtfmsg = g_strdup(args->info.rtfmsg.rtfmsg);
+					if (g_utf8_validate(args->info.rtfmsg.msg, strlen(args->info.rtfmsg.msg), NULL))
+						rtfmsg = g_strdup(args->info.rtfmsg.msg);
 				}
 				if (rtfmsg) {
 					serv_got_im(gc, userinfo->bn, rtfmsg, flags, time(NULL));
============================================================
--- libpurple/protocols/oscar/family_icbm.c	13c16ef6a0d7bc939530a112798509aceae3ac39
+++ libpurple/protocols/oscar/family_icbm.c	ecb6550278f98afc4c6046ba4c140b78fdf732cc
@@ -1966,7 +1966,7 @@ incomingim_ch2_icqserverrelay_free(Oscar
 static void
 incomingim_ch2_icqserverrelay_free(OscarData *od, IcbmArgsCh2 *args)
 {
-	g_free((char *)args->info.rtfmsg.rtfmsg);
+	g_free((char *)args->info.rtfmsg.msg);
 }
 
 /*
@@ -1980,33 +1980,34 @@ incomingim_ch2_icqserverrelay(OscarData 
 static void
 incomingim_ch2_icqserverrelay(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, aim_userinfo_t *userinfo, IcbmArgsCh2 *args, ByteStream *servdata)
 {
-	guint16 hdrlen, anslen, msglen;
+	guint16 hdrlen, msglen;
 
-	if (byte_stream_empty(servdata) < 24)
-		/* Someone sent us a short server relay ICBM.  Weird.  (Maybe?) */
-		return;
+	args->destructor = (void *)incomingim_ch2_icqserverrelay_free;
 
-	hdrlen = byte_stream_getle16(servdata);
+#define SKIP_HEADER(expected_hdrlen) \
+	hdrlen = byte_stream_getle16(servdata); \
+	if (hdrlen != expected_hdrlen) { \
+		purple_debug_warning("oscar", "Expected to find a header with length " #expected_hdrlen "; ignoring message"); \
+		return; \
+	} \
 	byte_stream_advance(servdata, hdrlen);
 
-	hdrlen = byte_stream_getle16(servdata);
-	byte_stream_advance(servdata, hdrlen);
+	SKIP_HEADER(0x001b);
+	SKIP_HEADER(0x000e);
 
-	args->info.rtfmsg.msgtype = byte_stream_getle16(servdata);
+	args->info.rtfmsg.msgtype = byte_stream_get8(servdata);
+	/*
+	 * Copied from http://iserverd.khstu.ru/oscar/message.html:
+	 * xx      byte       message flags
+	 * xx xx   word (LE)  status code
+	 * xx xx   word (LE)  priority code
+	 *
+	 * We don't need any of these, so just skip them.
+	 */
+	byte_stream_advance(servdata, 1 + 2 + 2);
 
-	anslen = byte_stream_getle32(servdata);
-	byte_stream_advance(servdata, anslen);
-
 	msglen = byte_stream_getle16(servdata);
-	args->info.rtfmsg.rtfmsg = byte_stream_getstr(servdata, msglen);
-
-	args->info.rtfmsg.fgcolor = byte_stream_getle32(servdata);
-	args->info.rtfmsg.bgcolor = byte_stream_getle32(servdata);
-
-	hdrlen = byte_stream_getle32(servdata);
-	byte_stream_advance(servdata, hdrlen);
-
-	args->destructor = (void *)incomingim_ch2_icqserverrelay_free;
+	args->info.rtfmsg.msg = byte_stream_getstr(servdata, msglen);
 }
 
 static void
============================================================
--- libpurple/protocols/oscar/oscar.h	53ed96cb43820175def510f7ed5cd12ddb4130b7
+++ libpurple/protocols/oscar/oscar.h	ef1804ff64db9acf7e5f33350d0135b765d4e84f
@@ -997,10 +997,8 @@ struct _IcbmArgsCh2
 			struct aim_chat_roominfo roominfo;
 		} chat;
 		struct {
-			guint16 msgtype;
-			guint32 fgcolor;
-			guint32 bgcolor;
-			const char *rtfmsg;
+			guint8 msgtype;
+			const char *msg;
 		} rtfmsg;
 		struct {
 			guint16 subtype;


More information about the Commits mailing list