--- /dev/null
+Return-Path: <jrollins@finestructure.net>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 77454431FC2\r
+ for <notmuch@notmuchmail.org>; Fri, 19 Jul 2013 08:36:43 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -2.3\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id mlcSlktu4gYG for <notmuch@notmuchmail.org>;\r
+ Fri, 19 Jul 2013 08:36:36 -0700 (PDT)\r
+Received: from outgoing-mail.its.caltech.edu (outgoing-mail.its.caltech.edu\r
+ [131.215.239.19])\r
+ by olra.theworths.org (Postfix) with ESMTP id EF6D7431FD0\r
+ for <notmuch@notmuchmail.org>; Fri, 19 Jul 2013 08:36:35 -0700 (PDT)\r
+Received: from earth-doxen.imss.caltech.edu (localhost [127.0.0.1])\r
+ by earth-doxen-postvirus (Postfix) with ESMTP id 9E43C66E00AA\r
+ for <notmuch@notmuchmail.org>; Fri, 19 Jul 2013 08:36:33 -0700 (PDT)\r
+X-Spam-Scanned: at Caltech-IMSS on earth-doxen by amavisd-new\r
+Received: from finestructure.net (lair.fifthhorseman.net [108.58.6.98])\r
+ (Authenticated sender: jrollins)\r
+ by earth-doxen-submit (Postfix) with ESMTP id BAA9266E0172\r
+ for <notmuch@notmuchmail.org>; Fri, 19 Jul 2013 08:36:31 -0700 (PDT)\r
+Received: by finestructure.net (Postfix, from userid 1000)\r
+ id 38F8262962; Fri, 19 Jul 2013 08:36:12 -0700 (PDT)\r
+From: Jameson Graef Rollins <jrollins@finestructure.net>\r
+To: Notmuch Mail <notmuch@notmuchmail.org>\r
+Subject: [PATCH] crypto: return NULL cryptoctx if protocol string is empty.\r
+Date: Fri, 19 Jul 2013 08:36:12 -0700\r
+Message-Id: <1374248172-14199-1-git-send-email-jrollins@finestructure.net>\r
+X-Mailer: git-send-email 1.7.10.4\r
+In-Reply-To: <id:51E95500.8000404@fifthhorseman.net>\r
+References: <id:51E95500.8000404@fifthhorseman.net>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Fri, 19 Jul 2013 15:36:43 -0000\r
+\r
+Badly formed messages that don't specify a protocol in\r
+signed/encrypted parts, end up with a protocol of NULL. strcasecmp in\r
+notmuch_crypto_get_context then segfaults when trying to check it\r
+against known protocols. If the protocol is NULL, just return an\r
+empty context immediately (with appropriate message.)\r
+---\r
+ crypto.c | 5 +++++\r
+ 1 file changed, 5 insertions(+)\r
+\r
+diff --git a/crypto.c b/crypto.c\r
+index 9736517..6f4a6db 100644\r
+--- a/crypto.c\r
++++ b/crypto.c\r
+@@ -69,6 +69,11 @@ notmuch_crypto_get_context (notmuch_crypto_t *crypto, const char *protocol)\r
+ {\r
+ notmuch_crypto_context_t *cryptoctx = NULL;\r
+ \r
++ if (! protocol) {\r
++ fprintf (stderr, "Cryptographic protocol is empty.\n");\r
++ return cryptoctx;\r
++ }\r
++\r
+ /* As per RFC 1847 section 2.1: "the [protocol] value token is\r
+ * comprised of the type and sub-type tokens of the Content-Type".\r
+ * As per RFC 1521 section 2: "Content-Type values, subtypes, and\r
+-- \r
+1.7.10.4\r
+\r