gpg: Do not bail on an invalid packet in the local keyring.
authorWerner Koch <wk@gnupg.org>
Tue, 21 May 2019 15:27:42 +0000 (17:27 +0200)
committerWerner Koch <wk@gnupg.org>
Tue, 21 May 2019 15:27:42 +0000 (17:27 +0200)
* g10/keydb.c (parse_keyblock_image): Treat invalid packet special.
--

This is in particular useful to run --list-keys on a keyring with
corrupted packets.  The extra flush is to keep the diagnostic close to
the regular --list-key output.

Signed-off-by: Werner Koch <wk@gnupg.org>
g10/keydb.c

index 45eb4aa..a7691bb 100644 (file)
@@ -1242,8 +1242,15 @@ parse_keyblock_image (iobuf_t iobuf, int pk_no, int uid_no,
        }
       if (err)
         {
+          es_fflush (es_stdout);
           log_error ("parse_keyblock_image: read error: %s\n",
                      gpg_strerror (err));
+          if (gpg_err_code (err) == GPG_ERR_INV_PACKET)
+            {
+              free_packet (pkt, &parsectx);
+              init_packet (pkt);
+              continue;
+            }
           err = gpg_error (GPG_ERR_INV_KEYRING);
           break;
         }