From 1c7e9be1732ebdf547484d1ee1d3efa59c28c7cc Mon Sep 17 00:00:00 2001 From: Pietro Cerutti Date: Wed, 21 Aug 2019 09:17:36 +0000 Subject: [PATCH] Fix segfault in PGP key selection Fixes #1809 --- ncrypt/pgpkey.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ncrypt/pgpkey.c b/ncrypt/pgpkey.c index 813fca781..c108b1d3a 100644 --- a/ncrypt/pgpkey.c +++ b/ncrypt/pgpkey.c @@ -1114,9 +1114,9 @@ struct PgpKeyInfo *pgp_getkeybyaddr(struct Address *a, KeyFlags abilities, /** * pgp_getkeybystr - Find a PGP key by string - * @param cp String to match - * @param abilities Abilities to match, see #KeyFlags - * @param keyring PGP keyring to use + * @param cp String to match, can be empty but cannot be NULL + * @param abilities Abilities to match, see #KeyFlags + * @param keyring PGP keyring to use * @retval ptr Matching PGP key */ struct PgpKeyInfo *pgp_getkeybystr(const char *cp, KeyFlags abilities, enum PgpRing keyring) @@ -1130,7 +1130,7 @@ struct PgpKeyInfo *pgp_getkeybystr(const char *cp, KeyFlags abilities, enum PgpR size_t l; const char *ps = NULL, *pl = NULL, *pfcopy = NULL, *phint = NULL; - char *p = mutt_str_strdup(cp); + char *p = strdup(cp); // mutt_str_strdup converts "" into NULL, see #1809 l = mutt_str_strlen(p); if ((l > 0) && (p[l - 1] == '!')) p[l - 1] = 0; -- 2.50.1