changeset 5345:bfe98c4d331e

[gaim-migrate @ 5721] ICQ has a maximum password length of 8 characters, apparently. I made Gaim truncate that shizzle for ICQ. This fixes this: http://sourceforge.net/tracker/?func=detail&aid=732409&group_id=235&atid=100235 committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sat, 10 May 2003 15:33:48 +0000
parents fda2d94b9434
children c1e7c3f72128
files src/protocols/oscar/aim.h src/protocols/oscar/auth.c src/protocols/oscar/icq.c
diffstat 3 files changed, 27 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/oscar/aim.h	Sat May 10 12:47:17 2003 +0000
+++ b/src/protocols/oscar/aim.h	Sat May 10 15:33:48 2003 +0000
@@ -119,6 +119,11 @@
  */
 #define MAXCHATMSGLEN 512
 
+/**
+ * Maximum length for the password of an ICQ account
+ */
+#define MAXICQPASSLEN 8
+
 #define AIM_MD5_STRING "AOL Instant Messenger (SM)"
 
 /*
--- a/src/protocols/oscar/auth.c	Sat May 10 12:47:17 2003 +0000
+++ b/src/protocols/oscar/auth.c	Sat May 10 15:33:48 2003 +0000
@@ -7,7 +7,7 @@
  */
 
 #define FAIM_INTERNAL
-#include <aim.h> 
+#include <aim.h>
 
 #include "md5.h"
 
@@ -156,10 +156,14 @@
 {
 	aim_frame_t *fr;
 	aim_tlvlist_t *tl = NULL;
+	int passwdlen;
 	char *password_encoded;
 
-	if (!(password_encoded = (char *) malloc(strlen(password))))
+	passwdlen = strlen(password);
+	if (!(password_encoded = (char *)malloc(passwdlen+1)))
 		return -ENOMEM;
+	if (passwdlen > MAXICQPASSLEN)
+		passwdlen = MAXICQPASSLEN;
 
 	if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x01, 1152))) {
 		free(password_encoded);
@@ -170,7 +174,7 @@
 
 	aimbs_put32(&fr->data, 0x00000001); /* FLAP Version */
 	aim_addtlvtochain_raw(&tl, 0x0001, strlen(sn), sn);
-	aim_addtlvtochain_raw(&tl, 0x0002, strlen(password), password_encoded);
+	aim_addtlvtochain_raw(&tl, 0x0002, passwdlen, password_encoded);
 
 	if (ci->clientstring)
 		aim_addtlvtochain_raw(&tl, 0x0003, strlen(ci->clientstring), ci->clientstring);
--- a/src/protocols/oscar/icq.c	Sat May 10 12:47:17 2003 +0000
+++ b/src/protocols/oscar/icq.c	Sat May 10 15:33:48 2003 +0000
@@ -105,12 +105,20 @@
 	return 0;
 }
 
+/**
+ * Change your ICQ password.
+ *
+ * @param sess The oscar session
+ * @param passwd The new password.  If this is longer than 8 characters it 
+ *        will be truncated.
+ * @return Return 0 if no errors, otherwise return the error number.
+ */
 faim_export int aim_icq_changepasswd(aim_session_t *sess, const char *passwd)
 {
 	aim_conn_t *conn;
 	aim_frame_t *fr;
 	aim_snacid_t snacid;
-	int bslen;
+	int bslen, passwdlen;
 
 	if (!passwd)
 		return -EINVAL;
@@ -118,7 +126,10 @@
 	if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0015)))
 		return -EINVAL;
 
-	bslen = 2+4+2+2+2+2+strlen(passwd)+1;
+	passwdlen = strlen(passwd);
+	if (passwdlen > MAXICQPASSLEN)
+		passwdlen = MAXICQPASSLEN;
+	bslen = 2+4+2+2+2+2+passwdlen+1;
 
 	if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 4 + bslen)))
 		return -ENOMEM;
@@ -135,8 +146,8 @@
 	aimbs_putle16(&fr->data, 0x07d0); /* I command thee. */
 	aimbs_putle16(&fr->data, snacid); /* eh. */
 	aimbs_putle16(&fr->data, 0x042e); /* shrug. */
-	aimbs_putle16(&fr->data, strlen(passwd)+1);
-	aimbs_putraw(&fr->data, passwd, strlen(passwd));
+	aimbs_putle16(&fr->data, passwdlen+1);
+	aimbs_putraw(&fr->data, passwd, passwdlen);
 	aimbs_putle8(&fr->data, '\0');
 
 	aim_tx_enqueue(sess, fr);