changeset 26323:bee0e8ddfebc

I think I'm just going to apply this patch. I don't really see how it could break anything, anyway. Should fix NTLM authentication on big-endian systems. Fixes #4315.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Sat, 28 Mar 2009 05:34:25 +0000
parents ed44004c333c
children b0a91fc541e0
files ChangeLog libpurple/ntlm.c
diffstat 2 files changed, 23 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat Mar 28 05:12:24 2009 +0000
+++ b/ChangeLog	Sat Mar 28 05:34:25 2009 +0000
@@ -7,6 +7,7 @@
 	* It should no longer be possible to end up with duplicates of buddies
 	  in a group on the buddy list.
 	* Removed the unmaintained and unneeded toc protocol plugin.
+	* Fixed NTLM authentication on big-endian systems.
 
 	XMPP:
 	* Add support for in-band bytestreams for file transfers (XEP-0047).
--- a/libpurple/ntlm.c	Sat Mar 28 05:12:24 2009 +0000
+++ b/libpurple/ntlm.c	Sat Mar 28 05:34:25 2009 +0000
@@ -110,7 +110,6 @@
 #endif
 };
 
-/* TODO: Will this work on both little-endian and big-endian machines? */
 gchar *
 purple_ntlm_gen_type1(const gchar *hostname, const gchar *domain)
 {
@@ -132,12 +131,12 @@
 	tmsg->protocol[5] = 'S';
 	tmsg->protocol[6] = 'P';
 	tmsg->protocol[7] = '\0';
-	tmsg->type      = 0x00000001;
-	tmsg->flags     = 0x0000b203;
-	tmsg->dom_len1  = tmsg->dom_len2 = domainlen;
-	tmsg->dom_off   = sizeof(struct type1_message) + hostnamelen;
-	tmsg->host_len1 = tmsg->host_len2 = hostnamelen;
-	tmsg->host_off  = sizeof(struct type1_message);
+	tmsg->type      = GUINT32_TO_LE(0x00000001);
+	tmsg->flags     = GUINT32_TO_LE(0x0000b203);
+	tmsg->dom_len1  = tmsg->dom_len2 = GUINT16_TO_LE(domainlen);
+	tmsg->dom_off   = GUINT32_TO_LE(sizeof(struct type1_message) + hostnamelen);
+	tmsg->host_len1 = tmsg->host_len2 = GUINT16_TO_LE(hostnamelen);
+	tmsg->host_off  = GUINT32_TO_LE(sizeof(struct type1_message));
 	memcpy(msg + tmsg->host_off, hostname, hostnamelen);
 	memcpy(msg + tmsg->dom_off, domain, domainlen);
 
@@ -157,7 +156,7 @@
 	tmsg = (struct type2_message*)purple_base64_decode(type2, &retlen);
 	memcpy(nonce, tmsg->nonce, 8);
 	if (flags != NULL)
-		*flags = tmsg->flags;
+		*flags = GUINT16_FROM_LE(tmsg->flags);
 	g_free(tmsg);
 
 	return nonce;
@@ -268,27 +267,27 @@
 	tmsg->protocol[4] = 'S';
 	tmsg->protocol[5] = 'S';
 	tmsg->protocol[6] = 'P';
-	tmsg->type = 0x00000003;
-	tmsg->lm_resp_len1 = tmsg->lm_resp_len2 = 0x18;
-	tmsg->lm_resp_off = sizeof(struct type3_message) + domainlen + usernamelen + hostnamelen;
-	tmsg->nt_resp_len1 = tmsg->nt_resp_len2 = 0x18;
-	tmsg->nt_resp_off = sizeof(struct type3_message) + domainlen + usernamelen + hostnamelen + 0x18;
+	tmsg->type = GUINT32_TO_LE(0x00000003);
+	tmsg->lm_resp_len1 = tmsg->lm_resp_len2 = GUINT16_TO_LE(0x18);
+	tmsg->lm_resp_off = GUINT32_TO_LE(sizeof(struct type3_message) + domainlen + usernamelen + hostnamelen);
+	tmsg->nt_resp_len1 = tmsg->nt_resp_len2 = GUINT16_TO_LE(0x18);
+	tmsg->nt_resp_off = GUINT32_TO_LE(sizeof(struct type3_message) + domainlen + usernamelen + hostnamelen + 0x18);
 
-	tmsg->dom_len1 = tmsg->dom_len2 = domainlen;
-	tmsg->dom_off = sizeof(struct type3_message);
+	tmsg->dom_len1 = tmsg->dom_len2 = GUINT16_TO_LE(domainlen);
+	tmsg->dom_off = GUINT32_TO_LE(sizeof(struct type3_message));
 
-	tmsg->user_len1 = tmsg->user_len2 = usernamelen;
-	tmsg->user_off = sizeof(struct type3_message) + domainlen;
+	tmsg->user_len1 = tmsg->user_len2 = GUINT16_TO_LE(usernamelen);
+	tmsg->user_off = GUINT32_TO_LE(sizeof(struct type3_message) + domainlen);
 
-	tmsg->host_len1 = tmsg->host_len2 = hostnamelen;
-	tmsg->host_off = sizeof(struct type3_message) + domainlen + usernamelen;
+	tmsg->host_len1 = tmsg->host_len2 = GUINT16_TO_LE(hostnamelen);
+	tmsg->host_off = GUINT32_TO_LE(sizeof(struct type3_message) + domainlen + usernamelen);
 
 	if(flags) {
-		tmsg->sess_off = sizeof(struct type3_message) + domainlen + usernamelen + hostnamelen + 0x18 + 0x18;
-		tmsg->sess_len1 = tmsg->sess_len2 = 0x0010;
+		tmsg->sess_off = GUINT32_TO_LE(sizeof(struct type3_message) + domainlen + usernamelen + hostnamelen + 0x18 + 0x18);
+		tmsg->sess_len1 = tmsg->sess_len2 = GUINT16_TO_LE(0x0010);
 	}
 
-	tmsg->flags = 0x00008201;
+	tmsg->flags = GUINT32_TO_LE(0x00008201);
 
 	tmp = (char *)tmsg + sizeof(struct type3_message);
 
@@ -361,7 +360,7 @@
 
 	/* LCS Stuff */
 	if (flags) {
-		tmsg->flags = 0x409082d4;
+		tmsg->flags = GUINT32_TO_LE(0x409082d4);
 		gensesskey(sesskey, NULL);
 		memcpy(tmp, sesskey, 0x10);
 	}