/pidgin/main: 4eeb75c4ed61: Fix purple_hash_digest_to_str return...

Tomasz Wasilczyk twasilczyk at pidgin.im
Mon May 19 03:31:57 EDT 2014


Changeset: 4eeb75c4ed61449443453158901339811c6fa0d0
Author:	 Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date:	 2014-05-19 09:31 +0200
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/4eeb75c4ed61

Description:

Fix purple_hash_digest_to_str returned types

diffstat:

 libpurple/protocols/msn/notification.c |   6 +++---
 libpurple/util.c                       |  26 ++++++++++++++++++--------
 2 files changed, 21 insertions(+), 11 deletions(-)

diffs (102 lines):

diff --git a/libpurple/protocols/msn/notification.c b/libpurple/protocols/msn/notification.c
--- a/libpurple/protocols/msn/notification.c
+++ b/libpurple/protocols/msn/notification.c
@@ -1400,7 +1400,7 @@ url_cmd(MsnCmdProc *cmdproc, MsnCommand 
 	PurpleHash *hash;
 	gchar creds[33];
 	char *buf;
-	gssize diglen;
+	gboolean digest_ok;
 
 	gulong tmp_timestamp;
 
@@ -1421,11 +1421,11 @@ url_cmd(MsnCmdProc *cmdproc, MsnCommand 
 
 	hash = purple_md5_hash_new();
 	purple_hash_append(hash, (const guchar *)buf, strlen(buf));
-	diglen = purple_hash_digest_to_str(hash, creds, sizeof(creds));
+	digest_ok = purple_hash_digest_to_str(hash, creds, sizeof(creds));
 	g_object_unref(hash);
 	g_free(buf);
 
-	g_return_if_fail(diglen > 0);
+	g_return_if_fail(digest_ok);
 
 	g_free(session->passport_info.mail_url);
 	session->passport_info.mail_url =
diff --git a/libpurple/util.c b/libpurple/util.c
--- a/libpurple/util.c
+++ b/libpurple/util.c
@@ -4819,7 +4819,7 @@ gchar *purple_http_digest_calculate_sess
 {
 	PurpleHash *hasher;
 	gchar hash[33]; /* We only support MD5. */
-	gssize digest_len;
+	gboolean digest_ok;
 
 	g_return_val_if_fail(username != NULL, NULL);
 	g_return_val_if_fail(realm    != NULL, NULL);
@@ -4862,10 +4862,10 @@ gchar *purple_http_digest_calculate_sess
 		purple_hash_append(hasher, (guchar *)client_nonce, strlen(client_nonce));
 	}
 
-	digest_len = purple_hash_digest_to_str(hasher, hash, sizeof(hash));
+	digest_ok = purple_hash_digest_to_str(hasher, hash, sizeof(hash));
 	g_object_unref(hasher);
 
-	g_return_val_if_fail(digest_len > 0, NULL);
+	g_return_val_if_fail(digest_ok, NULL);
 
 	return g_strdup(hash);
 }
@@ -4883,7 +4883,7 @@ gchar *purple_http_digest_calculate_resp
 {
 	PurpleHash *hash;
 	static gchar hash2[33]; /* We only support MD5. */
-	gssize hash_len;
+	gboolean digest_ok;
 
 	g_return_val_if_fail(method      != NULL, NULL);
 	g_return_val_if_fail(digest_uri  != NULL, NULL);
@@ -4923,16 +4923,26 @@ gchar *purple_http_digest_calculate_resp
 
 		hash2 = purple_md5_hash_new();
 		purple_hash_append(hash2, (guchar *)entity, strlen(entity));
-		purple_hash_digest_to_str(hash2, entity_hash, sizeof(entity_hash));
+		digest_ok = purple_hash_digest_to_str(hash2, entity_hash, sizeof(entity_hash));
 		g_object_unref(hash2);
 
+		if (!digest_ok) {
+			g_object_unref(hash);
+			g_return_val_if_reached(NULL);
+		}
+
 		purple_hash_append(hash, (guchar *)":", 1);
 		purple_hash_append(hash, (guchar *)entity_hash, strlen(entity_hash));
 	}
 
-	purple_hash_digest_to_str(hash, hash2, sizeof(hash2));
+	digest_ok = purple_hash_digest_to_str(hash, hash2, sizeof(hash2));
 	purple_hash_reset(hash);
 
+	if (!digest_ok) {
+		g_object_unref(hash);
+		g_return_val_if_reached(NULL);
+	}
+
 	purple_hash_append(hash, (guchar *)session_key, strlen(session_key));
 	purple_hash_append(hash, (guchar *)":", 1);
 	purple_hash_append(hash, (guchar *)nonce, strlen(nonce));
@@ -4965,10 +4975,10 @@ gchar *purple_http_digest_calculate_resp
 	}
 
 	purple_hash_append(hash, (guchar *)hash2, strlen(hash2));
-	hash_len = purple_hash_digest_to_str(hash, hash2, sizeof(hash2));
+	digest_ok = purple_hash_digest_to_str(hash, hash2, sizeof(hash2));
 	g_object_unref(hash);
 
-	g_return_val_if_fail(hash_len > 0, NULL);
+	g_return_val_if_fail(digest_ok, NULL);
 
 	return g_strdup(hash2);
 }



More information about the Commits mailing list