pidgin: 70fa4cc3: I think I'm just going to apply this pat...

qulogic at pidgin.im qulogic at pidgin.im
Sat Mar 28 04:05:44 EDT 2009


-----------------------------------------------------------------
Revision: 70fa4cc384b7643ab1f296bdc2399bc208542a20
Ancestor: 52bb7db51e0d789ead64636c113d10cdab40eae3
Author: qulogic at pidgin.im
Date: 2009-03-28T05:34:25
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/70fa4cc384b7643ab1f296bdc2399bc208542a20

Modified files:
        ChangeLog libpurple/ntlm.c

ChangeLog: 

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.

-------------- next part --------------
============================================================
--- ChangeLog	d31d48f9db517249af2c86dd4ab2fb25616b989b
+++ ChangeLog	f08b140925db4f7e9c0e079742b18f897ed1e276
@@ -7,6 +7,7 @@ version 2.6.0 (??/??/2009):
 	* 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).
============================================================
--- libpurple/ntlm.c	c5d5ab802febf89079e00f43df7b6261169930a6
+++ libpurple/ntlm.c	98c6a642a158c154fe361d21a9056016c264fb12
@@ -110,7 +110,6 @@ struct type3_message {
 #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 @@ purple_ntlm_gen_type1(const gchar *hostn
 	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 @@ purple_ntlm_parse_type2(const gchar *typ
 	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 @@ purple_ntlm_gen_type3(const gchar *usern
 	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 @@ purple_ntlm_gen_type3(const gchar *usern
 
 	/* LCS Stuff */
 	if (flags) {
-		tmsg->flags = 0x409082d4;
+		tmsg->flags = GUINT32_TO_LE(0x409082d4);
 		gensesskey(sesskey, NULL);
 		memcpy(tmp, sesskey, 0x10);
 	}


More information about the Commits mailing list