unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Jameson Graef Rollins <jrollins@finestructure.net>
To: Mark Walters <markwalters1009@gmail.com>,
	Ben Gamari <bgamari.foss@gmail.com>,
	notmuch@notmuchmail.org
Subject: Re: Segmentation fault in notmuch search --format=json
Date: Tue, 07 Aug 2012 01:08:40 -0700	[thread overview]
Message-ID: <87pq73jf92.fsf@servo.finestructure.net> (raw)
In-Reply-To: <878vdrp4d9.fsf@qmul.ac.uk>

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

On Tue, Aug 07 2012, Mark Walters <markwalters1009@gmail.com> wrote:
> On Tue, 07 Aug 2012, Ben Gamari <bgamari.foss@gmail.com> wrote:
>> It seems some messages trigger a segmentation fault in
>> `do_search_threads()`. It appears the problem occurs (at least) when
>> `authors` is NULL.
>
> Hi thanks for the bug report and detailed debugging. I think I can see
> the problem and there is a test patch to fix it below, and this does
> appear to be a regression.
>
> In json.c the function json_quote_str explicitly checks/allows for a
> NULL pointer passed as a string and pretends it is just an empty
> string. That behaviour was lost in the move to structured formatters.
>
> A simple fix is to put this check for a null pointer in json_string in
> sprinter-json.c which is what this patch does.

Thanks Mark!  I was experiencing the same problem and this fixed the
issue before I even got a chance to respond.  This seems like a fine
solution.

> Incidentally this is the second time this bug has appeared: 
>
>         commit cacefbf3d6dd5bce0b60b3cdfce29bfa371dfaea
>         Author: David Edmondson <dme@dme.org>
>         Date:   Tue Apr 6 08:24:00 2010 +0100
>
>             json: Avoid calling strlen(NULL)
>                 
>                     MIME parts may have no filename, which previously resulted in calling
>                         strlen(NULL).
>
> so it really might be worth having a test for it!

Indeed!  I think the problematic email in this case was one with no
subject.

> Finally, I think nothing in json.c is used anymore so perhaps it
>  could be removed.

Agreed.

jamie.

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

  reply	other threads:[~2012-08-07  8:08 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-07  5:52 Segmentation fault in notmuch search --format=json Ben Gamari
2012-08-07  7:07 ` Mark Walters
2012-08-07  8:08   ` Jameson Graef Rollins [this message]
2012-08-07 12:49   ` Austin Clements
2012-08-07 19:48   ` [PATCH] sprinters: bugfix when NULL passed for a string Mark Walters
2012-08-08  1:36     ` Jameson Graef Rollins
2012-08-08  2:09     ` Austin Clements
2012-08-08  7:31       ` Mark Walters
2012-08-08 16:25         ` Jameson Graef Rollins

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87pq73jf92.fsf@servo.finestructure.net \
    --to=jrollins@finestructure.net \
    --cc=bgamari.foss@gmail.com \
    --cc=markwalters1009@gmail.com \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).