* getkey.c (get_pubkey_byname), import.c (import_one): Fix key selection
authorDavid Shaw <dshaw@jabberwocky.com>
Mon, 22 May 2006 16:53:09 +0000 (16:53 +0000)
committerDavid Shaw <dshaw@jabberwocky.com>
Mon, 22 May 2006 16:53:09 +0000 (16:53 +0000)
problem when auto-key-locate returns a list of keys, not all of which are
usable (revoked, expired, etc).  Noted by Simon Josefsson.

g10/ChangeLog
g10/getkey.c
g10/import.c

index 192b468..79eed36 100644 (file)
@@ -1,3 +1,10 @@
+2006-05-22  David Shaw  <dshaw@jabberwocky.com>
+
+       * getkey.c (get_pubkey_byname), import.c (import_one): Fix key
+       selection problem when auto-key-locate returns a list of keys, not
+       all of which are usable (revoked, expired, etc).  Noted by Simon
+       Josefsson.
+
 2006-04-26  David Shaw  <dshaw@jabberwocky.com>
 
        * keyserver.c (direct_uri_map): New.
index c9ae58c..f7c988a 100644 (file)
@@ -934,7 +934,7 @@ get_pubkey_byname (PKT_public_key *pk,
 
       for(akl=opt.auto_key_locate;akl;akl=akl->next)
        {
-         unsigned char *fpr;
+         unsigned char *fpr=NULL;
          size_t fpr_len;
 
          switch(akl->type)
index 3b7fa5e..81aa506 100644 (file)
@@ -696,9 +696,6 @@ import_one( const char *fname, KBNODE keyblock, struct stats_s *stats,
 
     pk = node->pkt->pkt.public_key;
 
-    if(fpr)
-      *fpr=fingerprint_from_pk(pk,NULL,fpr_len);
-
     keyid_from_pk( pk, keyid );
     uidnode = find_next_kbnode( keyblock, PKT_USER_ID );
 
@@ -981,6 +978,17 @@ import_one( const char *fname, KBNODE keyblock, struct stats_s *stats,
       }
     else if(new_key)
       {
+       if(fpr && stats->imported==1)
+         {
+           xfree(*fpr);
+           *fpr=fingerprint_from_pk(pk,NULL,fpr_len);
+         }
+       else
+         {
+           xfree(*fpr);
+           *fpr=NULL;
+         }
+
        revocation_present(keyblock);
        if(seckey_available(keyid)==0)
          check_prefs(keyblock);