changeset 13662:b198d0c26b83

[gaim-migrate @ 16064] Fix Coverity CID 26: A potential crash when the server sends us an incoming channel 2 ICBM of the ICQ server relay type but does not send the data normally associated with such an ICBM. This should never happen. Fix Coverity CID 45: A potential crash when the server sends us an incoming channel 2 ICBM but does not send the data normally associated with such an ICBM. This should never happen. Fix Coverity CID 47: A 1 byte memleak when signing on using the old blist method and not when using SSI. This never happens. As far as I can tell it has been like this since the beginning of time. It's a weird memleak. Fix Coverity CID 57: A memleak of the length of a screen name when searching for screen names by email address and the server returns a malformed SNAC. This should never happen. Fix Coverity CID 59: A memleak of the length of an ICBM when _parsing_ an outgoing ICBM. I don't believe this ever happens, and I suspect the code exists from a time when libfaim was perhaps being written so that it could be used in an AIM server (in addition to just a client). I should probably remove the function. Fix Coverity CID 132: A memleak of the length of the email address when searching for screen names by email address. Fix Coverity CID 146: Check the return value of read() and print a warning to the debug window. This code is only used when AOL enables their crazy AIM executable hash value stuff, which hasn't happened in 5 years or so. Fix Coverity CID 191: Comment out some code that isn't used. Fix Coverity CID 192: Get rid of a harmless assignment to a variable that wasn't used. Fix Coverity CID 194: Comment out some variables and code that isn't used. Fix Coverity CID 198: Get rid of a variable that wasn't used in gaim_ssi_parselist(). committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Wed, 19 Apr 2006 03:31:47 +0000
parents d845dc5712bb
children b76c6de0c3b5
files src/protocols/oscar/family_admin.c src/protocols/oscar/family_feedbag.c src/protocols/oscar/family_icbm.c src/protocols/oscar/family_userlookup.c src/protocols/oscar/oscar.c src/protocols/oscar/util.c
diffstat 6 files changed, 27 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/oscar/family_admin.c	Wed Apr 19 02:41:27 2006 +0000
+++ b/src/protocols/oscar/family_admin.c	Wed Apr 19 03:31:47 2006 +0000
@@ -224,17 +224,17 @@
 	int ret = 0;
 	aim_rxcallback_t userfunc;
 	guint16 status;
-	aim_tlvlist_t *tl;
+	/* aim_tlvlist_t *tl; */
 
 	status = byte_stream_get16(bs);
-	/* This is 0x0013 if unable to confirm at this time */
+	/* Status is 0x0013 if unable to confirm at this time */
 
-	tl = aim_tlvlist_read(bs);
+	/* tl = aim_tlvlist_read(bs); */
 
 	if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
 		ret = userfunc(od, conn, frame, status);
 
-	aim_tlvlist_free(&tl);
+	/* aim_tlvlist_free(&tl); */
 
 	return ret;
 }
--- a/src/protocols/oscar/family_feedbag.c	Wed Apr 19 02:41:27 2006 +0000
+++ b/src/protocols/oscar/family_feedbag.c	Wed Apr 19 03:31:47 2006 +0000
@@ -745,8 +745,8 @@
 	/* Find the parent */
 	if (!(parent = aim_ssi_itemlist_finditem(od->ssi.local, group, NULL, AIM_SSI_TYPE_GROUP))) {
 		/* Find the parent's parent (the master group) */
-		if (!(parent = aim_ssi_itemlist_find(od->ssi.local, 0x0000, 0x0000)))
-			if (!(parent = aim_ssi_itemlist_add(&od->ssi.local, NULL, 0x0000, 0x0000, AIM_SSI_TYPE_GROUP, NULL)))
+		if (aim_ssi_itemlist_find(od->ssi.local, 0x0000, 0x0000) == NULL)
+			if (aim_ssi_itemlist_add(&od->ssi.local, NULL, 0x0000, 0x0000, AIM_SSI_TYPE_GROUP, NULL) == NULL)
 				return -ENOMEM;
 		/* Add the parent */
 		if (!(parent = aim_ssi_itemlist_add(&od->ssi.local, group, 0xFFFF, 0x0000, AIM_SSI_TYPE_GROUP, NULL)))
@@ -1307,7 +1307,7 @@
 		od->ssi.received_data = 1;
 
 		if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
-			ret = userfunc(od, conn, frame, fmtver, od->ssi.numitems, od->ssi.official, od->ssi.timestamp);
+			ret = userfunc(od, conn, frame, fmtver, od->ssi.numitems, od->ssi.timestamp);
 	}
 
 	return ret;
--- a/src/protocols/oscar/family_icbm.c	Wed Apr 19 02:41:27 2006 +0000
+++ b/src/protocols/oscar/family_icbm.c	Wed Apr 19 03:31:47 2006 +0000
@@ -1306,6 +1306,7 @@
 		ret = userfunc(od, conn, frame, channel, sn, msg, icbmflags, flag1, flag2);
 
 	free(sn);
+	free(msg);
 	aim_tlvlist_free(&tlvlist);
 
 	return ret;
@@ -1808,16 +1809,11 @@
 		aim_chat_readroominfo(servdata, &args->info.chat.roominfo);
 
 	args->destructor = (void *)incomingim_ch2_chat_free;
-
-	return;
 }
 
 static void incomingim_ch2_icqserverrelay_free(OscarData *od, IcbmArgsCh2 *args)
 {
-
 	free((char *)args->info.rtfmsg.rtfmsg);
-
-	return;
 }
 
 /*
@@ -1832,6 +1828,10 @@
 {
 	guint16 hdrlen, anslen, msglen;
 
+	if (servdata == NULL)
+		/* Odd...  Oh well. */
+		return;
+
 	hdrlen = byte_stream_getle16(servdata);
 	byte_stream_advance(servdata, hdrlen);
 
@@ -1853,8 +1853,6 @@
 	byte_stream_advance(servdata, hdrlen);
 
 	args->destructor = (void *)incomingim_ch2_icqserverrelay_free;
-
-	return;
 }
 
 static void incomingim_ch2_sendfile_free(OscarData *od, IcbmArgsCh2 *args)
@@ -1923,6 +1921,11 @@
 	 * There's another block of TLVs embedded in the type 5 here.
 	 */
 	block1 = aim_tlv_gettlv(tlvlist, 0x0005, 1);
+	if (block1 == NULL)
+	{
+		/* The server sent us ch2 ICBM without ch2 info?  Weird. */
+		return 1;
+	}
 	byte_stream_init(&bbs, block1->value, block1->length);
 
 	/*
--- a/src/protocols/oscar/family_userlookup.c	Wed Apr 19 02:41:27 2006 +0000
+++ b/src/protocols/oscar/family_userlookup.c	Wed Apr 19 03:31:47 2006 +0000
@@ -72,7 +72,7 @@
 
 	frame = flap_frame_new(od, 0x02, 10+strlen(address));
 
-	snacid = aim_cachesnac(od, 0x000a, 0x0002, 0x0000, strdup(address), strlen(address)+1);
+	snacid = aim_cachesnac(od, 0x000a, 0x0002, 0x0000, address, strlen(address)+1);
 	aim_putsnac(&frame->data, 0x000a, 0x0002, 0x0000, snacid);
 
 	byte_stream_putstr(&frame->data, address);
@@ -93,10 +93,10 @@
 	char *cur = NULL, *buf = NULL;
 	aim_rxcallback_t userfunc;
 	aim_snac_t *snac2;
-	char *searchaddr = NULL;
+	const char *searchaddr = NULL;
 
 	if ((snac2 = aim_remsnac(od, snac->id)))
-		searchaddr = (char *)snac2->data;
+		searchaddr = (const char *)snac2->data;
 
 	tlvlist = aim_tlvlist_read(bs);
 	m = aim_tlvlist_count(&tlvlist);
@@ -114,6 +114,7 @@
 
 		j++;
 	}
+	free(cur);
 
 	aim_tlvlist_free(&tlvlist);
 
--- a/src/protocols/oscar/oscar.c	Wed Apr 19 02:41:27 2006 +0000
+++ b/src/protocols/oscar/oscar.c	Wed Apr 19 03:31:47 2006 +0000
@@ -1179,7 +1179,6 @@
 	oscar_data_addhandler(od, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_ERROR, gaim_ssi_parseerr, 0);
 	oscar_data_addhandler(od, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_RIGHTSINFO, gaim_ssi_parserights, 0);
 	oscar_data_addhandler(od, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_LIST, gaim_ssi_parselist, 0);
-	oscar_data_addhandler(od, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_NOLIST, gaim_ssi_parselist, 0);
 	oscar_data_addhandler(od, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_SRVACK, gaim_ssi_parseack, 0);
 	oscar_data_addhandler(od, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_ADD, gaim_ssi_parseadd, 0);
 	oscar_data_addhandler(od, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_RECVAUTH, gaim_ssi_authgiven, 0);
@@ -1454,7 +1453,11 @@
 		g_free(pos);
 		return;
 	}
-	read(pos->fd, m, 16);
+	if (read(pos->fd, m, 16) != 16)
+	{
+		gaim_debug_warning("oscar", "Could not read full AIM login hash "
+				"from " AIMHASHDATA "--that's bad.\n");
+	}
 	m[16] = '\0';
 	gaim_debug_misc("oscar", "Sending hash: ");
 	for (x = 0; x < 16; x++)
@@ -3351,6 +3354,7 @@
 }
 
 static int gaim_parse_evilnotify(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
+#ifdef CRAZY_WARNING
 	va_list ap;
 	guint16 newevil;
 	aim_userinfo_t *userinfo;
@@ -3360,7 +3364,6 @@
 	userinfo = va_arg(ap, aim_userinfo_t *);
 	va_end(ap);
 
-#ifdef CRAZY_WARNING
 	gaim_prpl_got_account_warning_level(account, (userinfo && userinfo->sn) ? userinfo->sn : NULL, (newevil/10.0) + 0.5);
 #endif
 
@@ -4633,7 +4636,6 @@
 	guint32 tmp;
 	va_list ap;
 	guint16 fmtver, numitems;
-	struct aim_ssi_item *items;
 	guint32 timestamp;
 
 	gc = od->gc;
@@ -4643,7 +4645,6 @@
 	va_start(ap, fr);
 	fmtver = (guint16)va_arg(ap, int);
 	numitems = (guint16)va_arg(ap, int);
-	items = va_arg(ap, struct aim_ssi_item *);
 	timestamp = va_arg(ap, guint32);
 	va_end(ap);
 
--- a/src/protocols/oscar/util.c	Wed Apr 19 02:41:27 2006 +0000
+++ b/src/protocols/oscar/util.c	Wed Apr 19 03:31:47 2006 +0000
@@ -98,11 +98,6 @@
 		last = next + 1;
 		next = strchr(last, dl);
 	}
-
-	if (curCount < theindex) {
-		toReturn = malloc(sizeof(char));
-		*toReturn = '\0';
-	}
 	next = strchr(last, dl);
 
 	if (curCount < theindex) {