checked in (request 36361) OBS-URL: https://build.opensuse.org/request/show/36361 OBS-URL: https://build.opensuse.org/package/show/GNOME:Factory/libgnome-keyring?expand=0&rev=8
90 lines
2.9 KiB
Diff
90 lines
2.9 KiB
Diff
commit cf04a806f7cbd12bfb664a481b7a551650cb85b2
|
|
Author: Stef Walter <stef@memberwebs.com>
|
|
Date: Sun Feb 14 04:23:58 2010 +0000
|
|
|
|
No assertion when password is not found.
|
|
|
|
Would crash when gnome_keyring_find_password_xx() was called and
|
|
no password was found.
|
|
|
|
Fixes bug #608709
|
|
|
|
diff --git a/library/gnome-keyring.c b/library/gnome-keyring.c
|
|
index c867787..8931fe5 100644
|
|
--- a/library/gnome-keyring.c
|
|
+++ b/library/gnome-keyring.c
|
|
@@ -4374,10 +4374,19 @@ find_password_2_reply (GkrOperation *op, GkrSession *session, gpointer user_data
|
|
static void
|
|
find_password_1_reply (GkrOperation *op, const char *path, gpointer user_data)
|
|
{
|
|
+ GkrCallback *cb;
|
|
+
|
|
+ /* All done, complete the operation here */
|
|
+ if (path == NULL) {
|
|
+ cb = gkr_operation_pop (op);
|
|
+ gkr_callback_invoke_res (cb, GNOME_KEYRING_RESULT_NO_MATCH);
|
|
+
|
|
/* We need a session to get the secret for this item */
|
|
- gkr_operation_push (op, find_password_2_reply, GKR_CALLBACK_OP_SESSION,
|
|
- g_strdup (path), g_free);
|
|
- gkr_session_negotiate (op);
|
|
+ } else {
|
|
+ gkr_operation_push (op, find_password_2_reply, GKR_CALLBACK_OP_SESSION,
|
|
+ g_strdup (path), g_free);
|
|
+ gkr_session_negotiate (op);
|
|
+ }
|
|
}
|
|
|
|
static GkrOperation*
|
|
diff --git a/library/tests/test-keyrings.c b/library/tests/test-keyrings.c
|
|
index 7f7f1fa..aeba0ff 100644
|
|
--- a/library/tests/test-keyrings.c
|
|
+++ b/library/tests/test-keyrings.c
|
|
@@ -480,6 +480,46 @@ DEFINE_TEST(find_password)
|
|
g_assert_cmpint (GNOME_KEYRING_RESULT_OK, ==, find_password_result);
|
|
}
|
|
|
|
+static GnomeKeyringResult find_no_password_result;
|
|
+
|
|
+static void
|
|
+done_find_no_password (GnomeKeyringResult res, const gchar* password, gpointer unused)
|
|
+{
|
|
+ find_no_password_result = res;
|
|
+ if(res == GNOME_KEYRING_RESULT_OK)
|
|
+ g_assert (password == NULL);
|
|
+ test_mainloop_quit ();
|
|
+}
|
|
+
|
|
+DEFINE_TEST(find_no_password)
|
|
+{
|
|
+ GnomeKeyringResult res;
|
|
+ gchar *password;
|
|
+ gpointer op;
|
|
+
|
|
+ /* Synchronous, valid*/
|
|
+ res = gnome_keyring_find_password_sync (&our_schema, &password,
|
|
+ "dog", "grunt",
|
|
+ "legs", 1000,
|
|
+ NULL);
|
|
+ g_assert_cmpint (GNOME_KEYRING_RESULT_OK, ==, res);
|
|
+ g_assert (password == NULL);
|
|
+
|
|
+ /* Asynchronous, less arguments */
|
|
+ find_no_password_result = GNOME_KEYRING_RESULT_CANCELLED;
|
|
+ op = gnome_keyring_find_password (&our_schema,
|
|
+ done_find_no_password, NULL, NULL,
|
|
+ "dog", "grunt",
|
|
+ "legs", 1000,
|
|
+ NULL);
|
|
+ g_assert (op != NULL);
|
|
+ g_assert (find_no_password_result == GNOME_KEYRING_RESULT_CANCELLED);
|
|
+
|
|
+ test_mainloop_run (2000);
|
|
+
|
|
+ g_assert_cmpint (GNOME_KEYRING_RESULT_OK, ==, find_no_password_result);
|
|
+}
|
|
+
|
|
static void
|
|
done_delete_password (GnomeKeyringResult res, gpointer data)
|
|
{
|