diff libpurple/ntlm.c @ 30884:c20f67f37d2b

propagate from branch 'im.pidgin.pidgin' (head aa3b95627ddc76842b7b33f30bce406d7a689dd8) to branch 'im.pidgin.soc.2010.msn-tlc' (head 33b8ae304dffd42211af00431430a5c492f7e6f0)
author masca@cpw.pidgin.im
date Fri, 29 Oct 2010 17:36:08 +0000
parents 943fce8ef142
children a13744df700c
line wrap: on
line diff
--- a/libpurple/ntlm.c	Wed Sep 22 21:09:50 2010 +0000
+++ b/libpurple/ntlm.c	Fri Oct 29 17:36:08 2010 +0000
@@ -152,9 +152,14 @@
 	static guint8 nonce[8];
 
 	tmsg = (struct type2_message*)purple_base64_decode(type2, &retlen);
-	memcpy(nonce, tmsg->nonce, 8);
-	if (flags != NULL)
-		*flags = GUINT16_FROM_LE(tmsg->flags);
+	if (tmsg != NULL && retlen >= (sizeof(struct type2_message) - 1)) {
+		memcpy(nonce, tmsg->nonce, 8);
+		if (flags != NULL)
+			*flags = GUINT16_FROM_LE(tmsg->flags);
+	} else {
+		purple_debug_error("ntlm", "Unable to parse type2 message - returning empty nonce.\n");
+		memset(nonce, 0, 8);
+	}
 	g_free(tmsg);
 
 	return nonce;