# HG changeset patch # User Mark Doliner # Date 1245736394 0 # Node ID 8cb0f676c70deb947f00e6e201bdd07a40787c63 # Parent 5fbcfcbd65515097afb18c432fe01e5d445834b6 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) diff -r 5fbcfcbd6551 -r 8cb0f676c70d libpurple/protocols/myspace/myspace.c --- a/libpurple/protocols/myspace/myspace.c Tue Jun 23 05:40:34 2009 +0000 +++ b/libpurple/protocols/myspace/myspace.c Tue Jun 23 05:53:14 2009 +0000 @@ -519,6 +519,18 @@ 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 @@ 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); diff -r 5fbcfcbd6551 -r 8cb0f676c70d libpurple/protocols/myspace/myspace.h --- a/libpurple/protocols/myspace/myspace.h Tue Jun 23 05:40:34 2009 +0000 +++ b/libpurple/protocols/myspace/myspace.h Tue Jun 23 05:53:14 2009 +0000 @@ -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