[ekg2-commit] r4222 - trunk/plugins/icq: trunk/plugins/icq/icq_snac_handlers_01service.c trunk/plugins/icq/icq_snac_handlers_04message.c trunk/plugins/icq/misc.c

SVN commit svn w toxygen.net
Czw, 7 Sie 2008, 20:35:36 CEST


Author: darkjames
Date: 2008-08-07 20:35:35 +0200 (Thu, 07 Aug 2008)
New Revision: 4222

Modified:
   trunk/plugins/icq/icq_snac_handlers_01service.c
   trunk/plugins/icq/icq_snac_handlers_04message.c
   trunk/plugins/icq/misc.c
Log:
wiechu idea of skipping bytes in icq_unpack() :)


Modified: trunk/plugins/icq/icq_snac_handlers_01service.c
===================================================================
--- trunk/plugins/icq/icq_snac_handlers_01service.c	2008-08-07 18:12:25 UTC (rev 4221)
+++ trunk/plugins/icq/icq_snac_handlers_01service.c	2008-08-07 18:35:35 UTC (rev 4222)
@@ -198,17 +198,9 @@
 		uint32_t level;
 	} pkt;
 
-	if (!ICQ_UNPACK(&buf, "WW", &pkt.status, &pkt.class))
+	if (!ICQ_UNPACK(&buf, "WW20I", &pkt.status, &pkt.class, &pkt.level))
 		return -1;
 
-	if (len < 20)
-		return -1;
-
-	buf += 20; len -= 20;
-
-	if (!ICQ_UNPACK(&buf, "I", &pkt.level))
-		return -1;
-
 	/* XXX, Miranda do smth here :> */
 
 	debug_error("XXX icq_snac_service_ratechange() %u %u %u\n", pkt.status, pkt.class, pkt.level);

Modified: trunk/plugins/icq/icq_snac_handlers_04message.c
===================================================================
--- trunk/plugins/icq/icq_snac_handlers_04message.c	2008-08-07 18:12:25 UTC (rev 4221)
+++ trunk/plugins/icq/icq_snac_handlers_04message.c	2008-08-07 18:35:35 UTC (rev 4222)
@@ -315,40 +315,16 @@
 	if (pkt.len == 0x1b && 1 /* XXX */) {
 		/* this can be v8 greeting message reply */
 		uint16_t version;
-		uint16_t seq2;
-		uint8_t msg_type, flags;
-		uint16_t status;
+		/* 27b unknowns from the msg we sent */
+		uint16_t seq2;					/* Message sequence (SEQ2) */
+		/* 12b Unknown */
+		uint8_t msg_type, flags;			/* Message type */
+		uint16_t status;				/* Status */
+		/* 2b Priority? */
 
-		if (!ICQ_UNPACK(&buf, "w", &version))
+		if (!ICQ_UNPACK(&buf, "w27w12ccw2", &version, &seq2, &msg_type, &flags, &status))
 			return -1;
 
-		/* unknowns from the msg we sent */
-		if (len < 27)
-			return -1;
-		buf += 27; len -= 27;
-
-		/* Message sequence (SEQ2) */
-		if (!ICQ_UNPACK(&buf, "w", &seq2))
-			return -1;
-
-		/* Unknown (12 bytes) */
-		if (len < 12)
-			return -1;
-		buf += 12; len -= 12;
-
-		/* Message type */
-		if (!ICQ_UNPACK(&buf, "cc", &msg_type, &flags))
-			return -1;
-
-		/* Status */
-		if (!ICQ_UNPACK(&buf, "w", &status))
-			return -1;
-
-		/* Priority? */
-		if (len < 2)
-			return -1;
-		buf += 2; len -= 2;
-
 		/* XXX, more cookies... */
 
 		icq_hexdump(DEBUG_ERROR, buf, len);

Modified: trunk/plugins/icq/misc.c
===================================================================
--- trunk/plugins/icq/misc.c	2008-08-07 18:12:25 UTC (rev 4221)
+++ trunk/plugins/icq/misc.c	2008-08-07 18:35:35 UTC (rev 4222)
@@ -17,6 +17,7 @@
  */
 
 #include <stdint.h>
+#include <stdlib.h>
 #include <stdarg.h>
 #include <string.h>
 #include <ctype.h>
@@ -239,6 +240,18 @@
 		return 0;
 
 	while (*format) {
+		if (*format >= '0' && *format <= '9') {
+			long int skip = strtol(format, &format, 10);
+
+			if (len < skip) {
+				debug_error("icq_unpack() len: %d skiplen: %ld\n", len, skip);
+				goto err2;
+			}
+
+			buf += skip; len -= skip;
+			continue;
+		}
+
 		switch (*format) {
 			case 'c':	/* uint8_t */
 			case 'C':



Więcej informacji o liście dyskusyjnej ekg2-commit