card: Fix a NULL-ptr deref in key listings.

* tools/card-tool-keys.c (get_matching_keys): Fix segv.
* tools/gpg-card-tool.c (main): Init info.

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2019-02-07 16:28:03 +01:00
parent 5bf1212000
commit df6ba6dfd2
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
2 changed files with 8 additions and 5 deletions

View File

@ -214,9 +214,12 @@ get_matching_keys (const unsigned char *keygrip, int protocol,
err = get_matching_keys (keygrip, GNUPG_PROTOCOL_OPENPGP, &kb);
if (!err || gpg_err_code (err) == GPG_ERR_NO_PUBKEY)
{
*keyblock_tail = kb;
keyblock_tail = &kb->next;
kb = NULL;
if (!err)
{
*keyblock_tail = kb;
keyblock_tail = &kb->next;
kb = NULL;
}
err = get_matching_keys (keygrip, GNUPG_PROTOCOL_CMS, &kb);
if (!err)
{

View File

@ -309,7 +309,7 @@ main (int argc, char **argv)
}
else
{
struct card_info_s info_buffer;
struct card_info_s info_buffer = { 0 };
card_info_t info = &info_buffer;
err = 0;
@ -2968,7 +2968,7 @@ interactive_loop (void)
int redisplay = 1; /* Whether to redisplay the main info. */
int allow_admin = 0; /* Whether admin commands are allowed. */
char *help_arg = NULL; /* Argument of the HELP command. */
struct card_info_s info_buffer;
struct card_info_s info_buffer = { 0 };
card_info_t info = &info_buffer;
char *p;
int i;