changeset 12388:4e045668b9d0

[gaim-migrate @ 14694] Smashing the stack is neither fun nor profitable! Having room for the NUL terminator is a good idea. committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Wed, 07 Dec 2005 10:38:52 +0000
parents 1112a9ef2cc6
children e024601d45c7
files plugins/ciphertest.c src/cipher.c src/cipher.h
diffstat 3 files changed, 12 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/ciphertest.c	Wed Dec 07 09:16:25 2005 +0000
+++ b/plugins/ciphertest.c	Wed Dec 07 10:38:52 2005 +0000
@@ -64,7 +64,7 @@
 cipher_test_md5() {
 	GaimCipher *cipher;
 	GaimCipherContext *context;
-	gchar digest[32];
+	gchar digest[33];
 	gboolean ret;
 	gint i = 0;
 
@@ -121,7 +121,7 @@
 cipher_test_sha1() {
 	GaimCipher *cipher;
 	GaimCipherContext *context;
-	gchar digest[40];
+	gchar digest[41];
 	gint i = 0;
 	gboolean ret;
 
--- a/src/cipher.c	Wed Dec 07 09:16:25 2005 +0000
+++ b/src/cipher.c	Wed Dec 07 10:38:52 2005 +0000
@@ -1635,7 +1635,8 @@
 	if(!gaim_cipher_context_digest(context, sizeof(digest), digest, &dlen))
 		return FALSE;
 
-	if(in_len < dlen * 2)
+	/* in_len must be greater than dlen * 2 so we have room for the NUL. */
+	if(in_len <= dlen * 2)
 		return FALSE;
 
 	for(n = 0; n < dlen; n++)
@@ -1791,7 +1792,7 @@
 {
 	GaimCipher *cipher;
 	GaimCipherContext *context;
-	gchar hash[32]; /* We only support MD5. */
+	gchar hash[33]; /* We only support MD5. */
 
 	g_return_val_if_fail(username != NULL, NULL);
 	g_return_val_if_fail(realm    != NULL, NULL);
@@ -1857,7 +1858,7 @@
 {
 	GaimCipher *cipher;
 	GaimCipherContext *context;
-	gchar hash2[32]; /* We only support MD5. */
+	static gchar hash2[33]; /* We only support MD5. */
 
 	g_return_val_if_fail(method      != NULL, NULL);
 	g_return_val_if_fail(digest_uri  != NULL, NULL);
--- a/src/cipher.h	Wed Dec 07 09:16:25 2005 +0000
+++ b/src/cipher.h	Wed Dec 07 10:38:52 2005 +0000
@@ -386,6 +386,12 @@
  */
 gpointer gaim_cipher_context_get_data(GaimCipherContext *context);
 
+/*@}*/
+/*****************************************************************************/
+/** @name Gaim Cipher HTTP Digest Helper Functions							 */
+/*****************************************************************************/
+/*@{*/
+
 /**
  * Calculates a session key for HTTP Digest authentation
  *