[seahorse/pgp/uids-listbox: 12/15] pgp-key: Use proper keyid equality in has_keyid()




commit 4b3fad0d1133f2550a8cba5de1346aebaa8f8434
Author: Niels De Graef <nielsdegraef gmail com>
Date:   Mon Aug 16 07:51:02 2021 +0200

    pgp-key: Use proper keyid equality in has_keyid()

 pgp/seahorse-pgp-key.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)
---
diff --git a/pgp/seahorse-pgp-key.c b/pgp/seahorse-pgp-key.c
index 686c8ad5..e1871f97 100644
--- a/pgp/seahorse-pgp-key.c
+++ b/pgp/seahorse-pgp-key.c
@@ -560,27 +560,19 @@ gboolean
 seahorse_pgp_key_has_keyid (SeahorsePgpKey *self, const char *match)
 {
     SeahorsePgpKeyPrivate *priv = seahorse_pgp_key_get_instance_private (self);
-    guint n_match;
 
     g_return_val_if_fail (SEAHORSE_PGP_IS_KEY (self), FALSE);
-    g_return_val_if_fail (match, FALSE);
-
-    n_match = strlen (match);
+    g_return_val_if_fail (match && *match, FALSE);
 
     for (guint i = 0; i < g_list_model_get_n_items (priv->subkeys); i++) {
         g_autoptr(SeahorsePgpSubkey) subkey = NULL;
         const char *keyid;
-        guint n_keyid;
 
         subkey = g_list_model_get_item (priv->subkeys, i);
         keyid = seahorse_pgp_subkey_get_keyid (subkey);
         g_return_val_if_fail (keyid, FALSE);
-        n_keyid = strlen (keyid);
-        if (n_match <= n_keyid) {
-            keyid += (n_keyid - n_match);
-            if (strncmp (keyid, match, n_match) == 0)
-                return TRUE;
-        }
+        if (seahorse_pgp_keyid_equal (keyid, match))
+            return TRUE;
     }
 
     return FALSE;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]