Mercurial > pidgin
diff libpurple/protocols/myspace/myspace.c @ 27155:8cb0f676c70d
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)
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Tue, 23 Jun 2009 05:53:14 +0000 |
parents | 5fbcfcbd6551 |
children | 1bbed9fd046b |
line wrap: on
line diff
--- 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);