[ekg2-commit] r4200 - trunk/plugins/icq: trunk/plugins/icq/icq_snac_handlers_01service.c trunk/plugins/icq/icq_snac_handlers_03buddy.c trunk/plugins/icq/misc.c trunk/plugins/icq/misc.h

SVN commit svn w toxygen.net
Śro, 6 Sie 2008, 21:22:49 CEST


Author: wiechu
Date: 2008-08-06 21:22:48 +0200 (Wed, 06 Aug 2008)
New Revision: 4200

Modified:
   trunk/plugins/icq/icq_snac_handlers_01service.c
   trunk/plugins/icq/icq_snac_handlers_03buddy.c
   trunk/plugins/icq/misc.c
   trunk/plugins/icq/misc.h
Log:
    icq fix

Modified: trunk/plugins/icq/icq_snac_handlers_01service.c
===================================================================
--- trunk/plugins/icq/icq_snac_handlers_01service.c	2008-08-06 16:23:59 UTC (rev 4199)
+++ trunk/plugins/icq/icq_snac_handlers_01service.c	2008-08-06 19:22:48 UTC (rev 4200)
@@ -6,6 +6,7 @@
  *
  * ekg2 port:
  *  (C) Copyright 2006-2008 Jakub Zawadzki <darkjames w darkjames.ath.cx>
+ *                     2008 Wiesław Ochmiński <wiechu w wiechu.com>
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License Version 2 as
@@ -273,17 +274,17 @@
 	for (t = tlvs; t; t = t->next) {
 		switch (t->type) {
 			case 0x03:
-				if (t->len != 4) { debug_error("icq_snac_service_reqinfo() [0x03] len != 4\n"); goto def; }
+				if (tvl_length_check("icq_snac_service_reqinfo()", t, 4)) goto def;
 				debug_white("icq_snac_service_reqinfo() Logon TS: %u\n", t->nr);
 				break;
 
 			case 0x05:
-				if (t->len != 4) { debug_error("icq_snac_service_reqinfo() [0x05] len != 4\n"); goto def; }
+				if (tvl_length_check("icq_snac_service_reqinfo()", t, 4)) goto def;
 				debug_white("icq_snac_service_reqinfo() ICQ Member since: %u\n", t->nr);
 				break;
 
 			case 0x0A:
-				if (t->len != 4) { debug_error("icq_snac_service_reqinfo() [0x0A] len != 4\n"); goto def; }
+				if (tvl_length_check("icq_snac_service_reqinfo()", t, 4)) goto def;
 				debug_white("icq_snac_service_reqinfo() External IP: %u.%u.%u.%u\n", t->buf[0], t->buf[1], t->buf[2], t->buf[3]);
 				break;
 

Modified: trunk/plugins/icq/icq_snac_handlers_03buddy.c
===================================================================
--- trunk/plugins/icq/icq_snac_handlers_03buddy.c	2008-08-06 16:23:59 UTC (rev 4199)
+++ trunk/plugins/icq/icq_snac_handlers_03buddy.c	2008-08-06 19:22:48 UTC (rev 4200)
@@ -6,6 +6,7 @@
  *
  * ekg2 port:
  *  (C) Copyright 2006-2008 Jakub Zawadzki <darkjames w darkjames.ath.cx>
+ *                     2008 Wiesław Ochmiński <wiechu w wiechu.com>
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License Version 2 as
@@ -77,8 +78,25 @@
 
 	for (t = tlvs; t; t = t->next) {
 
+		/* darkjames said: "I don't trust anything. Wiechu, check t->len" */
 		switch (t->type) {
+			case 0x01:
+				if (tvl_length_check("icq_snac_buddy_online()", t, 2))
+					continue;
+				break;
+			case 0x03:
+			case 0x05:
 			case 0x06:
+			case 0x0a:
+			case 0x0f:
+				if (tvl_length_check("icq_snac_buddy_online()", t, 4))
+					continue;
+				break;
+		}
+		/* now we've got trusted length */
+
+		switch (t->type) {
+			case 0x06:
 				/* User status
 				 *
 				 * ICQ service presence notifications use user status field which consist

Modified: trunk/plugins/icq/misc.c
===================================================================
--- trunk/plugins/icq/misc.c	2008-08-06 16:23:59 UTC (rev 4199)
+++ trunk/plugins/icq/misc.c	2008-08-06 19:22:48 UTC (rev 4200)
@@ -438,7 +438,7 @@
 		case EKG_STATUS_DND:		return ICQ_STATUS_DND;
 		case EKG_STATUS_FFC:		return ICQ_STATUS_FFC;
 		case EKG_STATUS_INVISIBLE:	return ICQ_STATUS_INVISIBLE;
-		/* XXX, ICQ_STATUS_OCCUPIED */
+		case EKG_STATUS_XA:		return ICQ_STATUS_OCCUPIED;	/* XXX good choice? */
 
 		default:			return STATUS_ICQONLINE;
 	}
@@ -450,7 +450,7 @@
 		case ICQ_STATUS_AWAY:		return EKG_STATUS_AWAY;
 		case ICQ_STATUS_DND:		return EKG_STATUS_DND;
 		case ICQ_STATUS_NA:		return EKG_STATUS_NA;
-		case ICQ_STATUS_OCCUPIED:	return EKG_STATUS_XA;
+		case ICQ_STATUS_OCCUPIED:	return EKG_STATUS_XA;	/* XXX good choice? */
 		case ICQ_STATUS_FFC:		return EKG_STATUS_FFC;
 		case ICQ_STATUS_INVISIBLE:	return EKG_STATUS_INVISIBLE;
 
@@ -458,6 +458,14 @@
 	}
 }
 
+int tvl_length_check(char *name, icq_tlv_t *t, int length) {
+	if (t->len == length)
+		return 0;
+
+	debug_error("%s Incorrect TVL type=0x%02x. Length=%d, should be %d.\n", name, t->type, t->len, length);
+	return 1;
+}
+
 /* hash password, ripped from micq */
 char *icq_encryptpw(const char *pw) {
 	uint8_t tb[] = { 0xf3, 0x26, 0x81, 0xc4, 0x39, 0x86, 0xdb, 0x92, 0x71, 0xa3, 0xb9, 0xe6, 0x53, 0x7a, 0x95, 0x7c };

Modified: trunk/plugins/icq/misc.h
===================================================================
--- trunk/plugins/icq/misc.h	2008-08-06 16:23:59 UTC (rev 4199)
+++ trunk/plugins/icq/misc.h	2008-08-06 19:22:48 UTC (rev 4200)
@@ -46,4 +46,7 @@
 
 status_t icq2ekg_status(int icq_status);
 
+/* misc */
+int tvl_length_check(char *name, icq_tlv_t *t, int length);
+
 #endif



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