1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

common: Make nvc_lookup more robust.

* common/name-value.c (nvc_first): Allow for NULL arg.
(nvc_lookup): Allow for PK being NULL.
--

GnuPG-bug-id: 6176
This commit is contained in:
Werner Koch 2022-09-01 17:35:41 +02:00
parent c26393a2cb
commit cd7570f02e
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B

View File

@ -538,21 +538,32 @@ nve_t
nvc_first (nvc_t pk)
{
nve_t entry;
if (!pk)
return NULL;
for (entry = pk->first; entry; entry = entry->next)
if (entry->name)
return entry;
return NULL;
}
/* Get the first entry with the given name. */
/* Get the first entry with the given name. Return NULL if it does
* not exist. */
nve_t
nvc_lookup (nvc_t pk, const char *name)
{
nve_t entry;
if (!pk)
return NULL;
for (entry = pk->first; entry; entry = entry->next)
if (entry->name && ascii_strcasecmp (entry->name, name) == 0)
return entry;
return NULL;
}