telepathy-gabble: sasl-channel: don't crash on Abort() then <challenge>
Will Thompson
wjt at kemper.freedesktop.org
Thu Dec 6 09:56:43 PST 2012
Module: telepathy-gabble
Branch: master
Commit: d096c9b10d5c0d7787dccd05cd3dae23ffed99a4
URL: http://cgit.freedesktop.org/telepathy/telepathy-gabble/commit/?id=d096c9b10d5c0d7787dccd05cd3dae23ffed99a4
Author: Will Thompson <will.thompson at collabora.co.uk>
Date: Tue Nov 13 18:02:15 2012 +0000
sasl-channel: don't crash on Abort() then <challenge>
---
src/server-sasl-channel.c | 37 +++++++++++++++++++++++++++----------
tests/twisted/sasl/abort.py | 2 +-
2 files changed, 28 insertions(+), 11 deletions(-)
diff --git a/src/server-sasl-channel.c b/src/server-sasl-channel.c
index a912911..0330d99 100644
--- a/src/server-sasl-channel.c
+++ b/src/server-sasl-channel.c
@@ -93,6 +93,7 @@ struct _GabbleServerSaslChannelPrivate
GHashTable *sasl_error_details;
/* Given to the Connection on request */
TpConnectionStatusReason disconnect_reason;
+ GError *wocky_auth_error /* = NULL */;
GSimpleAsyncResult *result;
};
@@ -275,6 +276,7 @@ gabble_server_sasl_channel_finalize (GObject *object)
g_free (priv->sasl_error);
g_hash_table_unref (priv->sasl_error_details);
+ g_clear_error (&priv->wocky_auth_error);
if (G_OBJECT_CLASS (gabble_server_sasl_channel_parent_class)->finalize)
G_OBJECT_CLASS (gabble_server_sasl_channel_parent_class)->finalize (object);
@@ -767,6 +769,9 @@ gabble_server_sasl_channel_abort_sasl (
break;
}
+ g_set_error (&priv->wocky_auth_error, WOCKY_AUTH_ERROR,
+ code, "Authentication aborted: %s", in_Debug_Message);
+
if (priv->result != NULL)
{
/* If Not_Started, we're returning failure from start_auth_async.
@@ -775,9 +780,8 @@ gabble_server_sasl_channel_abort_sasl (
* If Server_Succeeded, we're returning failure from success_async.
*/
- g_simple_async_result_set_error (priv->result, WOCKY_AUTH_ERROR,
- code,
- "Authentication aborted: %s", in_Debug_Message);
+ g_simple_async_result_set_from_error (priv->result,
+ priv->wocky_auth_error);
complete_operation (self, TRUE);
}
@@ -846,7 +850,7 @@ gabble_server_sasl_channel_challenge_async (GabbleServerSaslChannel *self,
g_assert (!tp_base_channel_is_destroyed ((TpBaseChannel *) self));
g_assert (priv->result == NULL);
- g_assert (priv->sasl_status == TP_SASL_STATUS_IN_PROGRESS);
+
/* it might be sensitive, and also might not be UTF-8 text, so just print
* the length */
DEBUG ("New challenge, %" G_GSIZE_FORMAT " bytes", challenge_data->len);
@@ -854,13 +858,26 @@ gabble_server_sasl_channel_challenge_async (GabbleServerSaslChannel *self,
priv->result = g_simple_async_result_new (G_OBJECT (self), callback,
user_data, gabble_server_sasl_channel_challenge_async);
- challenge_ay = g_array_sized_new (FALSE, FALSE, sizeof (gchar),
- challenge_data->len);
- g_array_append_vals (challenge_ay, challenge_data->str,
- challenge_data->len);
+ switch (priv->sasl_status)
+ {
+ case TP_SASL_STATUS_IN_PROGRESS:
+ challenge_ay = g_array_sized_new (FALSE, FALSE, sizeof (gchar),
+ challenge_data->len);
+ g_array_append_vals (challenge_ay, challenge_data->str,
+ challenge_data->len);
- tp_svc_channel_interface_sasl_authentication_emit_new_challenge (
- self, challenge_ay);
+ tp_svc_channel_interface_sasl_authentication_emit_new_challenge (
+ self, challenge_ay);
+ break;
+ case TP_SASL_STATUS_CLIENT_FAILED:
+ g_return_if_fail (priv->wocky_auth_error != NULL);
+ g_simple_async_result_set_from_error (priv->result,
+ priv->wocky_auth_error);
+ complete_operation (self, TRUE);
+ return;
+ default:
+ g_assert_not_reached ();
+ }
}
gboolean
diff --git a/tests/twisted/sasl/abort.py b/tests/twisted/sasl/abort.py
index 926c94c..fc54ead 100644
--- a/tests/twisted/sasl/abort.py
+++ b/tests/twisted/sasl/abort.py
@@ -174,6 +174,6 @@ if __name__ == '__main__':
# exec_test_(test_close_then_challenge)
# exec_test_(test_close_then_success)
exec_test_(test_close_then_failure)
- # exec_test_(test_abort_then_challenge)
+ exec_test_(test_abort_then_challenge)
# exec_test_(test_abort_then_success)
exec_test_(test_abort_then_failure)
More information about the telepathy-commits
mailing list