From: Jameson Graef Rollins Date: Fri, 19 Jul 2013 15:36:12 +0000 (+1700) Subject: [PATCH] crypto: return NULL cryptoctx if protocol string is empty. X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=5b10fa0ec65eeeef31885fc9805f4ad6bcccc838;p=notmuch-archives.git [PATCH] crypto: return NULL cryptoctx if protocol string is empty. --- diff --git a/b1/0966a6853d063c6082e0b4d5da79c76c51bafe b/b1/0966a6853d063c6082e0b4d5da79c76c51bafe new file mode 100644 index 000000000..7ee270104 --- /dev/null +++ b/b1/0966a6853d063c6082e0b4d5da79c76c51bafe @@ -0,0 +1,80 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 77454431FC2 + for ; Fri, 19 Jul 2013 08:36:43 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -2.3 +X-Spam-Level: +X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id mlcSlktu4gYG for ; + Fri, 19 Jul 2013 08:36:36 -0700 (PDT) +Received: from outgoing-mail.its.caltech.edu (outgoing-mail.its.caltech.edu + [131.215.239.19]) + by olra.theworths.org (Postfix) with ESMTP id EF6D7431FD0 + for ; Fri, 19 Jul 2013 08:36:35 -0700 (PDT) +Received: from earth-doxen.imss.caltech.edu (localhost [127.0.0.1]) + by earth-doxen-postvirus (Postfix) with ESMTP id 9E43C66E00AA + for ; Fri, 19 Jul 2013 08:36:33 -0700 (PDT) +X-Spam-Scanned: at Caltech-IMSS on earth-doxen by amavisd-new +Received: from finestructure.net (lair.fifthhorseman.net [108.58.6.98]) + (Authenticated sender: jrollins) + by earth-doxen-submit (Postfix) with ESMTP id BAA9266E0172 + for ; Fri, 19 Jul 2013 08:36:31 -0700 (PDT) +Received: by finestructure.net (Postfix, from userid 1000) + id 38F8262962; Fri, 19 Jul 2013 08:36:12 -0700 (PDT) +From: Jameson Graef Rollins +To: Notmuch Mail +Subject: [PATCH] crypto: return NULL cryptoctx if protocol string is empty. +Date: Fri, 19 Jul 2013 08:36:12 -0700 +Message-Id: <1374248172-14199-1-git-send-email-jrollins@finestructure.net> +X-Mailer: git-send-email 1.7.10.4 +In-Reply-To: +References: +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Fri, 19 Jul 2013 15:36:43 -0000 + +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.) +--- + crypto.c | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/crypto.c b/crypto.c +index 9736517..6f4a6db 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 +-- +1.7.10.4 +