aboutsummaryrefslogtreecommitdiffhomepage
path: root/crypto.c
diff options
context:
space:
mode:
authorGravatar Jameson Graef Rollins <jrollins@finestructure.net>2013-07-19 08:36:12 -0700
committerGravatar David Bremner <bremner@debian.org>2013-07-20 09:13:48 -0300
commit348437243c861cc355f10e548a7a973a60299a25 (patch)
tree5cf2ced3a69af287ce8f20ed812b1508c0e664cf /crypto.c
parent03e2def474d539f8852bfdf7fd18ea3d8940e73c (diff)
crypto: return NULL cryptoctx if protocol string is empty.
Badly formed messages that don't specify a protocol in signed/encrypted parts, end up with a protocol of NULL. strcasecmp in notmuch_crypto_get_context then segfaults when trying to check it against known protocols. If the protocol is NULL, just return an empty context immediately (with appropriate message.)
Diffstat (limited to 'crypto.c')
-rw-r--r--crypto.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/crypto.c b/crypto.c
index 9736517f..6f4a6db9 100644
--- a/crypto.c
+++ b/crypto.c
@@ -69,6 +69,11 @@ notmuch_crypto_get_context (notmuch_crypto_t *crypto, const char *protocol)
{
notmuch_crypto_context_t *cryptoctx = NULL;
+ if (! protocol) {
+ fprintf (stderr, "Cryptographic protocol is empty.\n");
+ return cryptoctx;
+ }
+
/* As per RFC 1847 section 2.1: "the [protocol] value token is
* comprised of the type and sub-type tokens of the Content-Type".
* As per RFC 1521 section 2: "Content-Type values, subtypes, and