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
This commit is contained in:
Giovanni Campagna 2012-02-13 15:54:46 +01:00
parent 92276c5e70
commit c5804c1929

View File

@ -229,22 +229,29 @@ get_secrets_keyring_cb (GnomeKeyringResult result,
GList *list, GList *list,
gpointer user_data) gpointer user_data)
{ {
ShellAgentRequest *closure = user_data; ShellAgentRequest *closure;
ShellNetworkAgent *self = closure->self; ShellNetworkAgent *self;
ShellNetworkAgentPrivate *priv = self->priv; ShellNetworkAgentPrivate *priv;
GError *error = NULL; GError *error = NULL;
gint n_found = 0; gint n_found = 0;
GList *iter; GList *iter;
GHashTable *outer; GHashTable *outer;
if (result == GNOME_KEYRING_RESULT_CANCELLED)
return;
closure = user_data;
self = closure->self;
priv = self->priv;
closure->keyring_op = NULL; closure->keyring_op = NULL;
if (result == GNOME_KEYRING_RESULT_CANCELLED) if (result == GNOME_KEYRING_RESULT_DENIED)
{ {
g_set_error (&error, g_set_error (&error,
NM_SECRET_AGENT_ERROR, NM_SECRET_AGENT_ERROR,
NM_SECRET_AGENT_ERROR_USER_CANCELED, 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); closure->callback (NM_SECRET_AGENT (closure->self), closure->connection, NULL, error, closure->callback_data);