changeset 10610:74cc119beceb

[gaim-migrate @ 12063] Better handling of nonYMSG packets in HEAD. I think needing this is madness. committer: Tailor Script <tailor@pidgin.im>
author Tim Ringenbach <marv@pidgin.im>
date Sat, 19 Feb 2005 02:38:07 +0000
parents 6239870efd8e
children 41a18bf60ee1
files src/protocols/yahoo/yahoo.c
diffstat 1 files changed, 22 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/yahoo/yahoo.c	Fri Feb 18 04:22:53 2005 +0000
+++ b/src/protocols/yahoo/yahoo.c	Sat Feb 19 02:38:07 2005 +0000
@@ -1954,6 +1954,28 @@
 		if (yd->rxlen < YAHOO_PACKET_HDRLEN)
 			return;
 
+		if (strncmp(yd->rxqueue, "YMSG", MIN(4, yd->rxlen)) != 0) {
+			/* HEY! This isn't even a YMSG packet. What
+			 * are you trying to pull? */
+			guchar *start;
+
+			gaim_debug_warning("yahoo", "Error in YMSG stream, got something not a YMSG packet!");
+			
+			start = memchr(yd->rxqueue, 'Y', yd->rxlen);
+			if (start) {
+				g_memmove(yd->rxqueue, start, yd->rxlen - (start - yd->rxqueue));
+				yd->rxlen -= start - yd->rxqueue;
+				continue;
+			} else {
+				/* hmm this could screw up with just the Y, YM, or YMS is at the very
+				   end of the packet */
+				g_free(yd->rxqueue);
+				yd->rxqueue = NULL;
+				yd->rxlen = 0;
+				return;
+			}
+		}
+
 		pos += 4; /* YMSG */
 		pos += 2;
 		pos += 2;