]> rtime.felk.cvut.cz Git - notmuch.git/commit
lib: fix handling of one character long directory names at top level
authorJani Nikula <jani@nikula.org>
Sun, 10 Apr 2016 19:43:22 +0000 (22:43 +0300)
committerDavid Bremner <david@tethera.net>
Tue, 12 Apr 2016 23:40:19 +0000 (20:40 -0300)
commita352d9ceaa7e08b7c9de294419ec4c323b81ca15
treedca7e72e2eed9b05cd85846349533ea188a1e166
parent0f6b399d5b2f925a75a69d7cda38dda5c67db7a1
lib: fix handling of one character long directory names at top level

The code to skip multiple slashes in _notmuch_database_split_path()
skips back one character too much. This is compensated by a +1 in the
length parameter to the strndup() call. Mostly this works fine, but if
the path is to a file under a top level directory with one character
long name, the directory part is mistaken to be part of the file name
(slash == path in code). The returned directory name will be the empty
string and the basename will be the full path, breaking the indexing
logic in notmuch new.

Fix the multiple slash skipping to keep the slash variable pointing at
the last slash, and adjust strndup() accordingly.

The bug was introduced in

commit e890b0cf4011fd9fd77ebd87343379e4a778888b
Author: Carl Worth <cworth@cworth.org>
Date:   Sat Dec 19 13:20:26 2009 -0800

    database: Store the parent ID for each directory document.

just a little over two months after the initial commit in the Notmuch
code history, making this the longest living bug in Notmuch to date.
lib/database.cc
test/T050-new.sh