pidgin: 30f572d2: Fixed the error triggered by the failing...

ivan.komarov at soc.pidgin.im ivan.komarov at soc.pidgin.im
Sat Oct 30 17:16:07 EDT 2010


----------------------------------------------------------------------
Revision: 30f572d2b51bbd14c6b0c0539e0ce299617b1aff
Parent:   526b69963df47630549fb41e56520c7824587f15
Author:   ivan.komarov at soc.pidgin.im
Date:     10/30/10 11:30:30
Branch:   im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/30f572d2b51bbd14c6b0c0539e0ce299617b1aff

Changelog: 

Fixed the error triggered by the failing 'byte_stream_bytes_left(bs) >= len'
check in byte_stream_getstr() when called from aim_parse_extstatus().

According to http://iserverd.khstu.ru/oscar/snac_01_21.html, we were
parsing type 0x0002 packets slightly wrongly: they don't have neither
flags nor length field; we were reading too much and that caused the assertion.

Since we didn't use the data from this type of packets anyway, I just removed
the parsing of them altogether.

Changes against parent 526b69963df47630549fb41e56520c7824587f15

  patched  libpurple/protocols/oscar/family_oservice.c

-------------- next part --------------
============================================================
--- libpurple/protocols/oscar/family_oservice.c	fb1102258d0c5d13cdc45db0ed91a2d62a941c29
+++ libpurple/protocols/oscar/family_oservice.c	db66f5772c64209ef7243005352966e7279a14d3
@@ -1041,63 +1041,45 @@ aim_parse_extstatus(OscarData *od, FlapC
 static int
 aim_parse_extstatus(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs)
 {
-	guint16 type;
-	guint8 flags, length;
+	guint16 type = byte_stream_get16(bs);
+	if (type == 0x0000 || type == 0x0001) {
+		/* buddy icon checksum */
+		/* not sure what the difference between 1 and 0 is */
+		guint8 flags = byte_stream_get8(bs);
+		guint8 length = byte_stream_get8(bs);
+		guint8 *md5 = byte_stream_getraw(bs, length);
 
-	type = byte_stream_get16(bs);
-	flags = byte_stream_get8(bs);
-	length = byte_stream_get8(bs);
-
-	/*
-	 * A flag of 0x01 could mean "this is the checksum we have for you"
-	 * A flag of 0x40 could mean "I don't have your icon, upload it"
-	 */
-
-	switch (type) {
-		case 0x0000:
-		case 0x0001: { /* buddy icon checksum */
-			/* not sure what the difference between 1 and 0 is */
-			guint8 *md5 = byte_stream_getraw(bs, length);
-
-			if ((flags == 0x00) || (flags == 0x41)) {
-				if (!flap_connection_getbytype(od, SNAC_FAMILY_BART) && !od->iconconnecting) {
-					od->iconconnecting = TRUE;
-					od->set_icon = TRUE;
-					aim_srv_requestnew(od, SNAC_FAMILY_BART);
-				} else {
-					PurpleAccount *account = purple_connection_get_account(od->gc);
-					PurpleStoredImage *img = purple_buddy_icons_find_account_icon(account);
-					if (img == NULL) {
-						aim_ssi_delicon(od);
-					} else {
-
-						purple_debug_info("oscar",
-										"Uploading icon to icon server\n");
-						aim_bart_upload(od, purple_imgstore_get_data(img),
-						                purple_imgstore_get_size(img));
-						purple_imgstore_unref(img);
-					}
-				}
-			} else if (flags == 0x81) {
+		if ((flags == 0x00) || (flags == 0x41)) {
+			if (!flap_connection_getbytype(od, SNAC_FAMILY_BART) && !od->iconconnecting) {
+				od->iconconnecting = TRUE;
+				od->set_icon = TRUE;
+				aim_srv_requestnew(od, SNAC_FAMILY_BART);
+			} else {
 				PurpleAccount *account = purple_connection_get_account(od->gc);
 				PurpleStoredImage *img = purple_buddy_icons_find_account_icon(account);
-				if (img == NULL)
+				if (img == NULL) {
 					aim_ssi_delicon(od);
-				else {
-					aim_ssi_seticon(od, md5, length);
+				} else {
+
+					purple_debug_info("oscar",
+									"Uploading icon to icon server\n");
+					aim_bart_upload(od, purple_imgstore_get_data(img),
+							purple_imgstore_get_size(img));
 					purple_imgstore_unref(img);
 				}
 			}
+		} else if (flags == 0x81) {
+			PurpleAccount *account = purple_connection_get_account(od->gc);
+			PurpleStoredImage *img = purple_buddy_icons_find_account_icon(account);
+			if (img == NULL)
+				aim_ssi_delicon(od);
+			else {
+				aim_ssi_seticon(od, md5, length);
+				purple_imgstore_unref(img);
+			}
+		}
 
-			g_free(md5);
-		} break;
-
-		case 0x0002: {
-			/* We just set an available message? */
-			/* there is a second length that is just for the message */
-			char *msg = byte_stream_getstr(bs, byte_stream_get16(bs));
-			g_free(msg);
-		} break;
+		g_free(md5);
 	}
 
 	return 0;


More information about the Commits mailing list