diff options
author | Werner Koch <wk@gnupg.org> | 2022-09-01 17:35:41 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2022-09-01 17:44:50 +0200 |
commit | cd7570f02efe0bc416cbc5dbce3e5e79b4f10011 (patch) | |
tree | c72719b30a6102d533f268b54edba1885f48c771 /common/name-value.c | |
parent | po: Update Japanese Translation. (diff) | |
download | gnupg2-cd7570f02efe0bc416cbc5dbce3e5e79b4f10011.tar.xz gnupg2-cd7570f02efe0bc416cbc5dbce3e5e79b4f10011.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
Diffstat (limited to 'common/name-value.c')
-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 103c35d1c..d1d0a3f6f 100644 --- a/common/name-value.c +++ b/common/name-value.c @@ -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; } |