[libgnome-keyring] Fix memory leak related to dbus_message_iter_get_signature()



commit 129921d0eb44414d49becf8f687295a8410405d4
Author: Stef Walter <stef memberwebs com>
Date:   Sun Aug 29 13:18:44 2010 +0000

    Fix memory leak related to dbus_message_iter_get_signature()
    
    Discovered by David Woodhouse. Need to free memory returned
    by dbus_message_iter_get_signature()

 library/gkr-session.c   |   18 ++++++++++++++++--
 library/gnome-keyring.c |   16 ++++++++++++++--
 2 files changed, 30 insertions(+), 4 deletions(-)
---
diff --git a/library/gkr-session.c b/library/gkr-session.c
index f8ee2dc..9869f59 100644
--- a/library/gkr-session.c
+++ b/library/gkr-session.c
@@ -137,6 +137,8 @@ static gboolean
 decode_open_session_plain (DBusMessage *message, const char **path)
 {
 	DBusMessageIter iter, variant;
+	char *signature;
+	gboolean equal;
 
 	g_assert (message);
 	g_assert (path);
@@ -147,8 +149,13 @@ decode_open_session_plain (DBusMessage *message, const char **path)
 	if (!dbus_message_iter_init (message, &iter))
 		g_return_val_if_reached (FALSE);
 	dbus_message_iter_recurse (&iter, &variant);
-	if (!g_str_equal (dbus_message_iter_get_signature (&variant), "s"))
+
+	signature = dbus_message_iter_get_signature (&variant);
+	equal = g_str_equal (signature, "s");
+	dbus_free (signature);
+	if (!equal)
 		return FALSE;
+
 	if (!dbus_message_iter_next (&iter))
 		g_return_val_if_reached (FALSE);
 	dbus_message_iter_get_basic (&iter, path);
@@ -216,8 +223,10 @@ static gboolean
 decode_open_session_aes (DBusMessage *message, gcry_mpi_t *peer, const char **path)
 {
 	DBusMessageIter iter, variant, array;
+	char *signature;
 	gcry_error_t gcry;
 	guchar *buffer;
+	gboolean equal;
 	int n_buffer;
 
 	g_assert (message);
@@ -230,8 +239,13 @@ decode_open_session_aes (DBusMessage *message, gcry_mpi_t *peer, const char **pa
 	if (!dbus_message_iter_init (message, &iter))
 		g_return_val_if_reached (FALSE);
 	dbus_message_iter_recurse (&iter, &variant);
-	if (!g_str_equal (dbus_message_iter_get_signature (&variant), "ay"))
+
+	signature = dbus_message_iter_get_signature (&variant);
+	equal = g_str_equal (signature, "ay");
+	dbus_free (signature);
+	if (!equal)
 		return FALSE;
+
 	dbus_message_iter_recurse (&variant, &array);
 	dbus_message_iter_get_fixed_array (&array, &buffer, &n_buffer);
 	if (!dbus_message_iter_next (&iter))
diff --git a/library/gnome-keyring.c b/library/gnome-keyring.c
index 1c07766..7dab32c 100644
--- a/library/gnome-keyring.c
+++ b/library/gnome-keyring.c
@@ -367,6 +367,8 @@ decode_xlock_completed (DBusMessage *reply, gboolean *dismissed,
 	DBusMessageIter variant, iter, array;
 	dbus_bool_t bval;
 	const char *path;
+	char *signature;
+	gboolean equal;
 
 	g_assert (reply);
 	g_assert (dismissed);
@@ -388,7 +390,11 @@ decode_xlock_completed (DBusMessage *reply, gboolean *dismissed,
 	if (!dbus_message_iter_next (&iter))
 		g_return_val_if_reached (FALSE);
 	dbus_message_iter_recurse (&iter, &variant);
-	if (!g_str_equal (dbus_message_iter_get_signature (&variant), "ao"))
+
+	signature = dbus_message_iter_get_signature (&variant);
+	equal = g_str_equal (signature, "ao");
+	dbus_free (signature);
+	if (!equal)
 		return FALSE;
 
 	g_return_val_if_fail (dbus_message_iter_get_arg_type (&variant) == DBUS_TYPE_ARRAY, FALSE);
@@ -2683,6 +2689,8 @@ item_create_1_create_prompt_reply (GkrOperation *op, DBusMessage *reply, gpointe
 
 	DBusMessageIter iter, variant;
 	const char *path;
+	char *signature;
+	gboolean equal;
 
 	if (gkr_operation_handle_errors (op, reply))
 		return;
@@ -2699,7 +2707,11 @@ item_create_1_create_prompt_reply (GkrOperation *op, DBusMessage *reply, gpointe
 
 	/* Dig out the variant */
 	dbus_message_iter_recurse (&iter, &variant);
-	if (!g_str_equal (dbus_message_iter_get_signature (&variant), "o")) {
+
+	signature = dbus_message_iter_get_signature (&variant);
+	equal = g_str_equal (signature, "o");
+	dbus_free (signature);
+	if (!equal) {
 		gkr_operation_complete (op, decode_invalid_response (reply));
 		return;
 	}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]