core: Fix a few checks for number of fields in keylist result parser.

* src/keylist.c (keylist_colon_handler): Check for correct number of
fields.
--

This prevents NULL pointer dereferencing with older versions of gpg
that may output less fields.
This commit is contained in:
Ingo Klöcker 2021-06-02 10:20:26 +02:00
parent 27aa7c4a0f
commit 5512133de4

View File

@ -734,7 +734,7 @@ keylist_colon_handler (void *priv, char *line)
} }
/* Field 18 has the compliance flags. */ /* Field 18 has the compliance flags. */
if (fields >= 17 && *field[17]) if (fields >= 18 && *field[17])
PARSE_COMPLIANCE_FLAGS (field[17], subkey); PARSE_COMPLIANCE_FLAGS (field[17], subkey);
if (fields >= 20) if (fields >= 20)
@ -817,7 +817,7 @@ keylist_colon_handler (void *priv, char *line)
} }
/* Field 18 has the compliance flags. */ /* Field 18 has the compliance flags. */
if (fields >= 17 && *field[17]) if (fields >= 18 && *field[17])
PARSE_COMPLIANCE_FLAGS (field[17], subkey); PARSE_COMPLIANCE_FLAGS (field[17], subkey);
break; break;
@ -1015,7 +1015,7 @@ keylist_colon_handler (void *priv, char *line)
return 0; return 0;
assert (opd->tmp_keysig == key->_last_uid->_last_keysig); assert (opd->tmp_keysig == key->_last_uid->_last_keysig);
if (fields >= 4) if (fields >= 5)
{ {
/* Field 2 has the subpacket type. */ /* Field 2 has the subpacket type. */
int type = atoi (field[1]); int type = atoi (field[1]);