]> the.earth.li Git - onak.git/commitdiff
cscvs to tla changeset 35
authorJonathan McDowell <noodles@earth.li>
Mon, 31 May 2004 23:47:12 +0000 (23:47 +0000)
committerJonathan McDowell <noodles@earth.li>
Mon, 31 May 2004 23:47:12 +0000 (23:47 +0000)
Author: noodles
Date: 2002/11/15 15:29:40
Make getfullkeyid in keydb.c not assert if the key isn't found.

keydb.c
keydb.h

diff --git a/keydb.c b/keydb.c
index c5b07c628dfd2040d3152311dc85bec31ce729ad..3acf7112bd110a9a8ebf3ef308d32144dbcda427 100644 (file)
--- a/keydb.c
+++ b/keydb.c
@@ -89,7 +89,7 @@ struct ll *getkeysigs(uint64_t keyid)
  *     @keyid: The 32bit keyid.
  *
  *     This function maps a 32bit key id to the full 64bit one. It returns the
- *     full keyid.
+ *     full keyid. If the key isn't found a keyid of 0 is returned.
  */
 uint64_t getfullkeyid(uint64_t keyid)
 {
@@ -97,8 +97,13 @@ uint64_t getfullkeyid(uint64_t keyid)
 
        if (keyid < 0x100000000LL) {
                fetch_key(keyid, &publickey, false);
-               keyid = get_keyid(publickey);
-               free_publickey(publickey);
+               if (publickey != NULL) {
+                       keyid = get_keyid(publickey);
+                       free_publickey(publickey);
+                       publickey = NULL;
+               } else {
+                       keyid = 0;
+               }
        }
        
        return keyid;
diff --git a/keydb.h b/keydb.h
index e9bcb6751f275fc1d8607527419ddb9b882e7ae2..4ad761be28f8cb5491a54726caa63d7e4e4e9972 100644 (file)
--- a/keydb.h
+++ b/keydb.h
@@ -120,7 +120,7 @@ struct ll *getkeysigs(uint64_t keyid);
  *     @keyid: The 32bit keyid.
  *
  *     This function maps a 32bit key id to the full 64bit one. It returns the
- *     full keyid.
+ *     full keyid. If the key isn't found a keyid of 0 is returned.
  */
 uint64_t getfullkeyid(uint64_t keyid);