From 930920d5106e01d511dc339171ec3254e3d8771e Mon Sep 17 00:00:00 2001 From: Tomi Ollila Date: Sat, 18 Mar 2017 00:28:48 +0200 Subject: [PATCH 1/8] lib/message.cc: fix Coverity finding (use after free) The object where pointer to `data` was received was deleted before it was used in _notmuch_string_list_append(). Relevant Coverity messages follow: 3: extract Assigning: data = std::__cxx11::string(message->doc.()).c_str(), which extracts wrapped state from temporary of type std::__cxx11::string. 4: dtor_free The internal representation of temporary of type std::__cxx11::string is freed by its destructor. 5: use after free: Wrapper object use after free (WRAPPER_ESCAPE) Using internal representation of destroyed object local data. (cherry picked from commit 06adc276682d1d5f73d78df2e898ad4191eb4499) --- lib/message.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/message.cc b/lib/message.cc index 9d3e8071..a91e69e0 100644 --- a/lib/message.cc +++ b/lib/message.cc @@ -849,9 +849,9 @@ _notmuch_message_ensure_filename_list (notmuch_message_t *message) * * It would be nice to do the upgrade of the document directly * here, but the database is likely open in read-only mode. */ - const char *data; - data = message->doc.get_data ().c_str (); + std::string datastr = message->doc.get_data (); + const char *data = datastr.c_str (); if (data == NULL) INTERNAL_ERROR ("message with no filename"); From 8ef0d05ad77db68044e437e939c60bed07e169f1 Mon Sep 17 00:00:00 2001 From: David Bremner Date: Sun, 19 Mar 2017 09:39:06 -0300 Subject: [PATCH 2/8] debian: changelog stanza for 0.23.7-2 --- debian/changelog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/debian/changelog b/debian/changelog index f3167549..8b05d602 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +notmuch (0.23.7-2) unstable; urgency=medium + + * Cherry pick 06adc276, fix use after free in libnotmuch4 + + -- David Bremner Sun, 19 Mar 2017 09:38:17 -0300 + notmuch (0.23.7-1) unstable; urgency=medium * Move test suite $GNUPGHOME to /tmp to avoid problems with long build paths. From 704bd3d8a249b4041aa6a4204032f2b336f374e8 Mon Sep 17 00:00:00 2001 From: David Bremner Date: Tue, 28 Mar 2017 08:09:02 -0300 Subject: [PATCH 3/8] test: add known broken test for dump header Apparently nobody uses the list of "what was included in the dump" --- test/T240-dump-restore.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/T240-dump-restore.sh b/test/T240-dump-restore.sh index faa10364..7ea35953 100755 --- a/test/T240-dump-restore.sh +++ b/test/T240-dump-restore.sh @@ -2,6 +2,14 @@ test_description="\"notmuch dump\" and \"notmuch restore\"" . ./test-lib.sh || exit 1 +NOTMUCH_NEW > /dev/null +test_begin_subtest "dump header" +test_subtest_known_broken +cat < EXPECTED +#notmuch-dump batch-tag:2 config,properties,tags +EOF +notmuch dump > OUTPUT +test_expect_equal_file EXPECTED OUTPUT add_email_corpus test_expect_success 'Dumping all tags' \ From 1f3c7916f82774cacbfbb0fbc9d0e0aaae9399b3 Mon Sep 17 00:00:00 2001 From: David Bremner Date: Tue, 28 Mar 2017 08:09:03 -0300 Subject: [PATCH 4/8] cli/dump: fix bug in dump header Fix copy paste error. --- notmuch-dump.c | 2 +- test/T240-dump-restore.sh | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/notmuch-dump.c b/notmuch-dump.c index e7965cea..0bb946f8 100644 --- a/notmuch-dump.c +++ b/notmuch-dump.c @@ -84,7 +84,7 @@ print_dump_header (gzFile output, int output_format, int include) sep = ","; } if (include & DUMP_INCLUDE_TAGS) { - gzprintf (output, "%sproperties", sep); + gzprintf (output, "%stags", sep); } gzputs (output, "\n"); } diff --git a/test/T240-dump-restore.sh b/test/T240-dump-restore.sh index 7ea35953..181def34 100755 --- a/test/T240-dump-restore.sh +++ b/test/T240-dump-restore.sh @@ -4,7 +4,6 @@ test_description="\"notmuch dump\" and \"notmuch restore\"" NOTMUCH_NEW > /dev/null test_begin_subtest "dump header" -test_subtest_known_broken cat < EXPECTED #notmuch-dump batch-tag:2 config,properties,tags EOF From d47e18411807b57cac9aaa29a7435a9f83720b81 Mon Sep 17 00:00:00 2001 From: David Bremner Date: Fri, 31 Mar 2017 07:55:17 -0300 Subject: [PATCH 5/8] cli/dump: bump dump format version to 3 No changes to the format of the body, but the header format was fixed, and version 2 headers probably shouldn't be relied on. --- doc/man1/notmuch-dump.rst | 2 +- notmuch-client.h | 2 +- test/T240-dump-restore.sh | 2 +- test/T590-libconfig.sh | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/man1/notmuch-dump.rst b/doc/man1/notmuch-dump.rst index ca048aeb..f3f2b394 100644 --- a/doc/man1/notmuch-dump.rst +++ b/doc/man1/notmuch-dump.rst @@ -95,7 +95,7 @@ Supported options for **dump** include The default is to include all available types of data. The option can be specified multiple times to select some subset. As - of version 2 of the dump format, there is a header line of the + of version 3 of the dump format, there is a header line of the following form | diff --git a/notmuch-client.h b/notmuch-client.h index 10991224..e8f17250 100644 --- a/notmuch-client.h +++ b/notmuch-client.h @@ -470,7 +470,7 @@ typedef enum dump_includes { #define DUMP_INCLUDE_DEFAULT (DUMP_INCLUDE_TAGS | DUMP_INCLUDE_CONFIG | DUMP_INCLUDE_PROPERTIES) -#define NOTMUCH_DUMP_VERSION 2 +#define NOTMUCH_DUMP_VERSION 3 int notmuch_database_dump (notmuch_database_t *notmuch, diff --git a/test/T240-dump-restore.sh b/test/T240-dump-restore.sh index 181def34..d45c9f87 100755 --- a/test/T240-dump-restore.sh +++ b/test/T240-dump-restore.sh @@ -5,7 +5,7 @@ test_description="\"notmuch dump\" and \"notmuch restore\"" NOTMUCH_NEW > /dev/null test_begin_subtest "dump header" cat < EXPECTED -#notmuch-dump batch-tag:2 config,properties,tags +#notmuch-dump batch-tag:3 config,properties,tags EOF notmuch dump > OUTPUT test_expect_equal_file EXPECTED OUTPUT diff --git a/test/T590-libconfig.sh b/test/T590-libconfig.sh index e8c078d5..1b308693 100755 --- a/test/T590-libconfig.sh +++ b/test/T590-libconfig.sh @@ -112,7 +112,7 @@ cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} EOF notmuch dump --include=config >OUTPUT cat <<'EOF' >EXPECTED -#notmuch-dump batch-tag:2 config +#notmuch-dump batch-tag:3 config #@ aaabefore beforeval #@ key%20with%20spaces value,%20with,%20spaces%21 #@ testkey1 testvalue1 From bc354159632f159079c9b6d793141dadaf2d619b Mon Sep 17 00:00:00 2001 From: David Bremner Date: Sat, 1 Apr 2017 09:15:30 -0300 Subject: [PATCH 6/8] NEWS: note dump header fix --- NEWS | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/NEWS b/NEWS index b5101218..f55e67ba 100644 --- a/NEWS +++ b/NEWS @@ -17,6 +17,12 @@ Fix several memory leaks in `notmuch show`. Update NEWS for 0.24 to mention schema changes. +Fix bug in dump header. + + The previous version of the dump header failed to mention the + inclusion of tags. This fix bumps the version number of the dump + format to 3. There are no other changes to the format. + Library Changes --------------- From 877cb04914ea30b9b6c4728ed92c8c10f0f4a022 Mon Sep 17 00:00:00 2001 From: David Bremner Date: Sat, 1 Apr 2017 09:18:56 -0300 Subject: [PATCH 7/8] debian: finalize changelog for 0.24.1-1 --- debian/changelog | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 9dc3b608..606dada5 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,11 @@ -notmuch (0.24.1-1) UNRELEASED; urgency=medium +notmuch (0.24.1-1) experimental; urgency=medium * Restore Xapian wildcard queries to from: and subject: + * Handle empty queries for from: and subject: + * Memory leaks in notmuch show fixed + * Fix bug notmuch dump header generation - -- David Bremner Sat, 25 Mar 2017 11:21:34 -0300 + -- David Bremner Sat, 01 Apr 2017 09:17:47 -0300 notmuch (0.24-1) experimental; urgency=medium From e64fdf889d0f78543557f5b72ebca1571caf497e Mon Sep 17 00:00:00 2001 From: David Bremner Date: Sat, 1 Apr 2017 09:29:38 -0300 Subject: [PATCH 8/8] NEWS: set release date --- NEWS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS b/NEWS index f55e67ba..a63e340e 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,4 @@ -Notmuch 0.24.1 (UNRELEASED) +Notmuch 0.24.1 (2017-04-01) =========================== General