diff options
author | Werner Koch <[email protected]> | 2022-09-01 15:35:41 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2022-09-01 15:35:41 +0000 |
commit | 8c22b00268bf5b2374cf7af69465a902b91946aa (patch) | |
tree | e3c1977e6b581f7b2e345494f71c7c2a77f100b8 | |
parent | Post release updates (diff) | |
download | gnupg-8c22b00268bf5b2374cf7af69465a902b91946aa.tar.gz gnupg-8c22b00268bf5b2374cf7af69465a902b91946aa.zip |
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
-rw-r--r-- | common/name-value.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/common/name-value.c b/common/name-value.c index 0e9e49ca1..b9b13d185 100644 --- a/common/name-value.c +++ b/common/name-value.c @@ -546,21 +546,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; } |