comparison libpurple/ntlm.c @ 31800: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 943fce8ef142
children
comparison
equal deleted inserted replaced
31799:e972e2161bf5 31800:a13744df700c
109 }; 109 };
110 110
111 gchar * 111 gchar *
112 purple_ntlm_gen_type1(const gchar *hostname, const gchar *domain) 112 purple_ntlm_gen_type1(const gchar *hostname, const gchar *domain)
113 { 113 {
114 int hostnamelen; 114 int hostnamelen,host_off;
115 int domainlen; 115 int domainlen,dom_off;
116 unsigned char *msg; 116 unsigned char *msg;
117 struct type1_message *tmsg; 117 struct type1_message *tmsg;
118 gchar *tmp; 118 gchar *tmp;
119 119
120 hostnamelen = strlen(hostname); 120 hostnamelen = strlen(hostname);
121 domainlen = strlen(domain); 121 domainlen = strlen(domain);
122 host_off = sizeof(struct type1_message);
123 dom_off = sizeof(struct type1_message) + hostnamelen;
122 msg = g_malloc0(sizeof(struct type1_message) + hostnamelen + domainlen); 124 msg = g_malloc0(sizeof(struct type1_message) + hostnamelen + domainlen);
123 tmsg = (struct type1_message*)msg; 125 tmsg = (struct type1_message*)msg;
124 tmsg->protocol[0] = 'N'; 126 tmsg->protocol[0] = 'N';
125 tmsg->protocol[1] = 'T'; 127 tmsg->protocol[1] = 'T';
126 tmsg->protocol[2] = 'L'; 128 tmsg->protocol[2] = 'L';
130 tmsg->protocol[6] = 'P'; 132 tmsg->protocol[6] = 'P';
131 tmsg->protocol[7] = '\0'; 133 tmsg->protocol[7] = '\0';
132 tmsg->type = GUINT32_TO_LE(0x00000001); 134 tmsg->type = GUINT32_TO_LE(0x00000001);
133 tmsg->flags = GUINT32_TO_LE(0x0000b203); 135 tmsg->flags = GUINT32_TO_LE(0x0000b203);
134 tmsg->dom_len1 = tmsg->dom_len2 = GUINT16_TO_LE(domainlen); 136 tmsg->dom_len1 = tmsg->dom_len2 = GUINT16_TO_LE(domainlen);
135 tmsg->dom_off = GUINT32_TO_LE(sizeof(struct type1_message) + hostnamelen); 137 tmsg->dom_off = GUINT32_TO_LE(dom_off);
136 tmsg->host_len1 = tmsg->host_len2 = GUINT16_TO_LE(hostnamelen); 138 tmsg->host_len1 = tmsg->host_len2 = GUINT16_TO_LE(hostnamelen);
137 tmsg->host_off = GUINT32_TO_LE(sizeof(struct type1_message)); 139 tmsg->host_off = GUINT32_TO_LE(host_off);
138 memcpy(msg + tmsg->host_off, hostname, hostnamelen); 140 memcpy(msg + host_off, hostname, hostnamelen);
139 memcpy(msg + tmsg->dom_off, domain, domainlen); 141 memcpy(msg + dom_off, domain, domainlen);
140 142
141 tmp = purple_base64_encode(msg, sizeof(struct type1_message) + hostnamelen + domainlen); 143 tmp = purple_base64_encode(msg, sizeof(struct type1_message) + hostnamelen + domainlen);
142 g_free(msg); 144 g_free(msg);
143 145
144 return tmp; 146 return tmp;