From c5804c19294cd0fb0e6670a6df957a95836af89c Mon Sep 17 00:00:00 2001 From: Giovanni Campagna Date: Mon, 13 Feb 2012 15:54:46 +0100 Subject: [PATCH] ShellNetworkAgent: don't access request fields if the operation is cancelled When the operation is cancelled by NetworkManager, the request is cancelled immediately. Later when gnome-keyring invokes the callback notifying the error we must therefore not access its memory. Previously the callback would mistakenly treat "cancelled" (which indicates a programmatic cancel) as "denied" (which means the user clicked "Cancel" on the keyring prompt) https://bugzilla.gnome.org/show_bug.cgi?id=658484 --- src/shell-network-agent.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/shell-network-agent.c b/src/shell-network-agent.c index b24999b75..964023694 100644 --- a/src/shell-network-agent.c +++ b/src/shell-network-agent.c @@ -229,22 +229,29 @@ get_secrets_keyring_cb (GnomeKeyringResult result, GList *list, gpointer user_data) { - ShellAgentRequest *closure = user_data; - ShellNetworkAgent *self = closure->self; - ShellNetworkAgentPrivate *priv = self->priv; + ShellAgentRequest *closure; + ShellNetworkAgent *self; + ShellNetworkAgentPrivate *priv; GError *error = NULL; gint n_found = 0; GList *iter; GHashTable *outer; + if (result == GNOME_KEYRING_RESULT_CANCELLED) + return; + + closure = user_data; + self = closure->self; + priv = self->priv; + closure->keyring_op = NULL; - if (result == GNOME_KEYRING_RESULT_CANCELLED) + if (result == GNOME_KEYRING_RESULT_DENIED) { g_set_error (&error, NM_SECRET_AGENT_ERROR, NM_SECRET_AGENT_ERROR_USER_CANCELED, - "The secret request was cancelled by the user"); + "Access to the secret storage was denied by the user"); closure->callback (NM_SECRET_AGENT (closure->self), closure->connection, NULL, error, closure->callback_data);