pidgin: aec1adb7: Fix a few problems with our myspace logi...

markdoliner at pidgin.im markdoliner at pidgin.im
Tue Jun 23 01:55:22 EDT 2009


-----------------------------------------------------------------
Revision: aec1adb73ee28586c6f762aabd481c41158b4d9f
Ancestor: 4538cb494f592d4dc496f982c8c2a393294e499b
Author: markdoliner at pidgin.im
Date: 2009-06-23T05:53:14
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/aec1adb73ee28586c6f762aabd481c41158b4d9f

Modified files:
        libpurple/protocols/myspace/myspace.c
        libpurple/protocols/myspace/myspace.h

ChangeLog: 

Fix a few problems with our myspace login response:
* email address should include the null terminator
* we should add padding
* don't send an incorrect ip address (instead, send nothing)

-------------- next part --------------
============================================================
--- libpurple/protocols/myspace/myspace.c	986899a4d43cb054d941140e67f9d485430ec91c
+++ libpurple/protocols/myspace/myspace.c	e391d751ad80315a861a6256a0b94b7e3e86168c
@@ -519,6 +519,18 @@ msim_status_types(PurpleAccount *acct)
 	return types;
 }
 
+/*
+ * TODO: This define is stolen from oscar.h.
+ *       It's also in yahoo.h.
+ *       It should be in libpurple/util.c
+ */
+#define msim_put32(buf, data) ( \
+		(*((buf)) = (unsigned char)((data)>>24)&0xff), \
+		(*((buf)+1) = (unsigned char)((data)>>16)&0xff), \
+		(*((buf)+2) = (unsigned char)((data)>>8)&0xff), \
+		(*((buf)+3) = (unsigned char)(data)&0xff), \
+		4)
+
 /**
  * Compute the base64'd login challenge response based on username, password, nonce, and IPs.
  *
@@ -619,15 +631,27 @@ msim_compute_login_response(const gchar 
 	purple_cipher_context_set_option(rc4, "key_len", (gpointer)0x10);
 	purple_cipher_context_set_key(rc4, key);
 
-	/* TODO: obtain IPs of network interfaces */
-
 	/* rc4 encrypt:
 	 * nonce1+email+IP list */
 
 	data = g_string_new(NULL);
 	g_string_append_len(data, nonce, NONCE_SIZE);
-	g_string_append(data, email);
+
+	/* Include the null terminator */
+	g_string_append_len(data, email, strlen(email) + 1);
+
+	while (data->len % 4 != 0)
+		g_string_append_c(data, 0xfb);
+
+#ifdef SEND_OUR_IP_ADDRESSES
+	/* TODO: Obtain IPs of network interfaces instead of using this hardcoded value */
+	g_string_set_size(data, data->len + 4);
+	msim_put32(data->str + data->len - 4, MSIM_LOGIN_IP_LIST_LEN);
 	g_string_append_len(data, MSIM_LOGIN_IP_LIST, MSIM_LOGIN_IP_LIST_LEN);
+#else
+	g_string_set_size(data, data->len + 4);
+	msim_put32(data->str + data->len - 4, 0);
+#endif /* !SEND_OUR_IP_ADDRESSES */
 
 	data_out = g_new0(guchar, data->len);
 
============================================================
--- libpurple/protocols/myspace/myspace.h	70d12885861c2707390aa645dfe16c402218c29f
+++ libpurple/protocols/myspace/myspace.h	d592752d6d66d8afacd8eb2503a380209c36f591
@@ -140,6 +140,7 @@
 /* Recognized challenge length */
 #define MSIM_AUTH_CHALLENGE_LENGTH  0x40
 
+#ifdef SEND_OUR_IP_ADDRESSES
 /* TODO: obtain IPs of network interfaces from user's machine, instead of
  * hardcoding these values below (used in msim_compute_login_response).
  * This is not immediately
@@ -152,6 +153,7 @@
 
 #define MSIM_LOGIN_IP_LIST  "\x00\x00\x00\x00\x05\x7f\x00\x00\x01\x00\x00\x00\x00\x0a\x00\x00\x40\xc0\xa8\x58\x01\xc0\xa8\x3c\x01"
 #define MSIM_LOGIN_IP_LIST_LEN         25
+#endif /* SEND_OUR_IP_ADDRESSES */
 
 /* Indexes into status string (0|1|2|3|..., but 0 always empty) */
 #define MSIM_STATUS_ORDINAL_EMPTY       0


More information about the Commits mailing list