unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Morgan Veyret <morgan.veyret@gmail.com>
To: David Bremner <david@tethera.net>, notmuch@notmuchmail.org
Subject: Re: BUG: maildir flags sync with database relative path results in corrupted filename
Date: Mon, 8 Jun 2015 20:41:37 +0200	[thread overview]
Message-ID: <CACMMjM+twCQ9MjB6H51eVW-izekpStNT5+u75LUu9rduG1CWEQ@mail.gmail.com> (raw)
In-Reply-To: <871thmivpt.fsf@maritornes.cs.unb.ca>

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

It does the job, now opening the database with a relative path raise
a NotmuchError.



On Mon, Jun 8, 2015 at 8:02 AM, David Bremner <david@tethera.net> wrote:

> Morgan Veyret <morgan.veyret@gmail.com> writes:
>
> >
> > As I understand it's expected that the database path should be absolute
> but
> > corrupting the database when the path is relative sounds dangerous.
>
> Thanks for the report.  I can see how this could happen, since the
> internal functions _notmuch_message_add_file_name and
> _notmuch_database_relative_path classify message filenames into absolute
> paths starting with the database path and paths relative to the database
> root.
>
> The obvious solution is to reject non-absolute paths in
> notmuch_database_open_verbose. A slightly friendlier approach would be
> to canonicalize the path, but this might have unforseen consequences for
> clients relying on the database path being exactly what they pass in.
>
> Can you see if the attached patch "fixes" it for you? You'll have to
> rebuild notmuch from source. The patch should apply to 0.20 or later.
>
>
> diff --git a/lib/database.cc b/lib/database.cc
> index 78a24f7..2a5b82a 100644
> --- a/lib/database.cc
> +++ b/lib/database.cc
> @@ -847,6 +847,12 @@ notmuch_database_open_verbose (const char *path,
>         goto DONE;
>      }
>
> +    if (path[0] != '/') {
> +       message = strdup ("Error: Database path must be absolute.\n");
> +       status = NOTMUCH_STATUS_FILE_ERROR;
> +       goto DONE;
> +    }
> +
>      if (! (notmuch_path = talloc_asprintf (local, "%s/%s", path,
> ".notmuch"))) {
>         message = strdup ("Out of memory\n");
>         status = NOTMUCH_STATUS_OUT_OF_MEMORY;
>
>

[-- Attachment #2: Type: text/html, Size: 2302 bytes --]

  reply	other threads:[~2015-06-08 18:41 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-07 15:12 BUG: maildir flags sync with database relative path results in corrupted filename Morgan Veyret
2015-06-08  6:02 ` David Bremner
2015-06-08 18:41   ` Morgan Veyret [this message]
2015-06-08 20:37     ` David Bremner
2015-06-10  7:17       ` [PATCH 1/2] lib: add NOTMUCH_STATUS_PATH_ERROR David Bremner
2015-06-10  7:17         ` [PATCH 2/2] lib: reject relative paths in n_d_{create,open}_verbose David Bremner
2015-06-11 20:21         ` [PATCH 1/2] lib: add NOTMUCH_STATUS_PATH_ERROR Tomi Ollila
2015-06-12  5:40           ` David Bremner

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=CACMMjM+twCQ9MjB6H51eVW-izekpStNT5+u75LUu9rduG1CWEQ@mail.gmail.com \
    --to=morgan.veyret@gmail.com \
    --cc=david@tethera.net \
    --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).