unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] crypto: return NULL cryptoctx if protocol string is empty.
       [not found] <id:51E95500.8000404@fifthhorseman.net>
@ 2013-07-19 15:36 ` Jameson Graef Rollins
  2013-07-19 15:57   ` Jameson Graef Rollins
  2013-07-20 12:36   ` David Bremner
  0 siblings, 2 replies; 3+ messages in thread
From: Jameson Graef Rollins @ 2013-07-19 15:36 UTC (permalink / raw)
  To: Notmuch Mail

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] crypto: return NULL cryptoctx if protocol string is empty.
  2013-07-19 15:36 ` [PATCH] crypto: return NULL cryptoctx if protocol string is empty Jameson Graef Rollins
@ 2013-07-19 15:57   ` Jameson Graef Rollins
  2013-07-20 12:36   ` David Bremner
  1 sibling, 0 replies; 3+ messages in thread
From: Jameson Graef Rollins @ 2013-07-19 15:57 UTC (permalink / raw)
  To: Notmuch Mail

[-- Attachment #1: Type: text/plain, Size: 466 bytes --]

On Fri, Jul 19 2013, Jameson Graef Rollins <jrollins@finestructure.net> wrote:
> 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.)

Fixes bug reported in id:87mwpiu4vi.fsf@zancas.localnet

jamie.

[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] crypto: return NULL cryptoctx if protocol string is empty.
  2013-07-19 15:36 ` [PATCH] crypto: return NULL cryptoctx if protocol string is empty Jameson Graef Rollins
  2013-07-19 15:57   ` Jameson Graef Rollins
@ 2013-07-20 12:36   ` David Bremner
  1 sibling, 0 replies; 3+ messages in thread
From: David Bremner @ 2013-07-20 12:36 UTC (permalink / raw)
  To: Jameson Graef Rollins, Notmuch Mail

Jameson Graef Rollins <jrollins@finestructure.net> writes:

> 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.)

Pushed, thanks for the fix

d

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-07-20 12:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <id:51E95500.8000404@fifthhorseman.net>
2013-07-19 15:36 ` [PATCH] crypto: return NULL cryptoctx if protocol string is empty Jameson Graef Rollins
2013-07-19 15:57   ` Jameson Graef Rollins
2013-07-20 12:36   ` David Bremner

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).