shell-network-agent: don't crash if a request isn't found

If a request isn't found in shell_network_agent_set_password() or
shell_network_agent_respond(), then g_return_if_fail() rather than
crashing. OTOH, if a request is not found in
shell_network_agent_cancel_get_secrets(), then just ignore it
silently, since that could legitimately happen.

https://bugzilla.gnome.org/show_bug.cgi?id=674961
This commit is contained in:
Dan Winship 2012-04-26 17:08:38 -04:00
parent 988fc52303
commit 8befcb9bba

View File

@ -409,6 +409,7 @@ shell_network_agent_set_password (ShellNetworkAgent *self,
priv = self->priv;
request = g_hash_table_lookup (priv->requests, request_id);
g_return_if_fail (request != NULL);
if (!request->is_vpn)
{
@ -438,6 +439,7 @@ shell_network_agent_respond (ShellNetworkAgent *self,
priv = self->priv;
request = g_hash_table_lookup (priv->requests, request_id);
g_return_if_fail (request != NULL);
if (response == SHELL_NETWORK_AGENT_USER_CANCELED)
{
@ -491,8 +493,18 @@ shell_network_agent_cancel_get_secrets (NMSecretAgent *agent,
gchar *request_id = g_strdup_printf ("%s/%s", connection_path, setting_name);
ShellAgentRequest *request = g_hash_table_lookup (priv->requests, request_id);
GError *error;
GError *error = g_error_new (NM_SECRET_AGENT_ERROR,
if (!request)
{
/* We've already sent the result, but the caller cancelled the
* operation before receiving that result.
*/
g_free (request_id);
return;
}
error = g_error_new (NM_SECRET_AGENT_ERROR,
NM_SECRET_AGENT_ERROR_AGENT_CANCELED,
"Canceled by NetworkManager");
request->callback (agent, request->connection, NULL, error, request->callback_data);