changeset 32258:a13744df700c

Fix NTLM endianness issue. Fixes #14163 committer: Ethan Blanton <elb@pidgin.im>
author jond578@gmail.com
date Tue, 16 Aug 2011 15:06:48 +0000
parents e972e2161bf5
children 65fc614f11e4
files COPYRIGHT libpurple/ntlm.c
diffstat 2 files changed, 9 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/COPYRIGHT	Tue Aug 16 15:03:35 2011 +0000
+++ b/COPYRIGHT	Tue Aug 16 15:06:48 2011 +0000
@@ -197,6 +197,7 @@
 Gustavo Giráldez
 Richard Gobeille
 Ian Goldberg
+Jon Goldberg
 Matthew Goldstein
 Michael Golden
 Charlie Gordon
--- a/libpurple/ntlm.c	Tue Aug 16 15:03:35 2011 +0000
+++ b/libpurple/ntlm.c	Tue Aug 16 15:06:48 2011 +0000
@@ -111,14 +111,16 @@
 gchar *
 purple_ntlm_gen_type1(const gchar *hostname, const gchar *domain)
 {
-	int hostnamelen;
-	int domainlen;
+	int hostnamelen,host_off;
+	int domainlen,dom_off;
 	unsigned char *msg;
 	struct type1_message *tmsg;
 	gchar *tmp;
 
 	hostnamelen = strlen(hostname);
 	domainlen = strlen(domain);
+	host_off = sizeof(struct type1_message);
+	dom_off = sizeof(struct type1_message) + hostnamelen;
 	msg = g_malloc0(sizeof(struct type1_message) + hostnamelen + domainlen);
 	tmsg = (struct type1_message*)msg;
 	tmsg->protocol[0] = 'N';
@@ -132,11 +134,11 @@
 	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->dom_off   = GUINT32_TO_LE(dom_off);
 	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);
+	tmsg->host_off  = GUINT32_TO_LE(host_off);
+	memcpy(msg + host_off, hostname, hostnamelen);
+	memcpy(msg + dom_off, domain, domainlen);
 
 	tmp = purple_base64_encode(msg, sizeof(struct type1_message) + hostnamelen + domainlen);
 	g_free(msg);