]> granicus.if.org Git - neomutt/commitdiff
Fix segfault in PGP key selection
authorPietro Cerutti <gahr@gahr.ch>
Wed, 21 Aug 2019 09:17:36 +0000 (09:17 +0000)
committerRichard Russon <rich@flatcap.org>
Wed, 21 Aug 2019 10:57:14 +0000 (11:57 +0100)
Fixes #1809

ncrypt/pgpkey.c

index 813fca7811988a0d15781751f90badd0130324c5..c108b1d3a64a0b66376204a699c5e45f7065ec2c 100644 (file)
@@ -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;