From a1203dacb219fd69929e8f589d7677c3f9e8a7fb Mon Sep 17 00:00:00 2001 From: Morgan Veyret Date: Sun, 7 Jun 2015 17:12:00 +0200 Subject: [PATCH] BUG: maildir flags sync with database relative path results in corrupted filename --- 2e/be2bb9e050888383da9b1a2ac613b6e9b0053d | 165 ++++++++++++++++++++++ 1 file changed, 165 insertions(+) create mode 100644 2e/be2bb9e050888383da9b1a2ac613b6e9b0053d diff --git a/2e/be2bb9e050888383da9b1a2ac613b6e9b0053d b/2e/be2bb9e050888383da9b1a2ac613b6e9b0053d new file mode 100644 index 000000000..632529ae5 --- /dev/null +++ b/2e/be2bb9e050888383da9b1a2ac613b6e9b0053d @@ -0,0 +1,165 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by arlo.cworth.org (Postfix) with ESMTP id 9FF4A6DE1502 + for ; Sun, 7 Jun 2015 08:12:05 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: -0.819 +X-Spam-Level: +X-Spam-Status: No, score=-0.819 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7, + RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] + autolearn=disabled +Received: from arlo.cworth.org ([127.0.0.1]) + by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id AEvp9rt8pa50 for ; + Sun, 7 Jun 2015 08:12:03 -0700 (PDT) +Received: from mail-yk0-f169.google.com (mail-yk0-f169.google.com + [209.85.160.169]) + by arlo.cworth.org (Postfix) with ESMTPS id 91DB36DE119C + for ; Sun, 7 Jun 2015 08:12:03 -0700 (PDT) +Received: by yked142 with SMTP id d142so42634253yke.3 + for ; Sun, 07 Jun 2015 08:12:00 -0700 (PDT) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; + h=mime-version:date:message-id:subject:from:to:content-type; + bh=HI0mdyek2BHH5raoTppJ9WxBvRbg4SjQD9MQnrPuFNw=; + b=RMdOqWz2xGBUTTMNC5oYDRIB2g+Wr5iZWgqSJcOvxrXJlFlKsZ7HX2r42TBTpZU4Gw + 60YC+PAwSU8wfL9B+qi1M3iQNW/QQwt+BWFgAafBtkOfz+7LFNe/+SKIzZxDUZMGyUE7 + a9wXnNeZ/35piX8cYZ0+lkyPDduhiXAPaQwO5SVb+Z3/Rgv5zlzBtj+913axru4gL4ve + 7lLUseLy/a5UONo0pq3iAhPb9MO1Ai7Ci8yBO5wu6GW7lSpw6/Cs0+WOXd9Ief2Op3KS + xUjldqQnLGqwgCuAJLO5qK8PWYT/pgRpkanvmM5of4f9lq5nz3PnKFCvLs9z8RnalhPY + FQBw== +MIME-Version: 1.0 +X-Received: by 10.129.119.7 with SMTP id s7mr11140481ywc.87.1433689920436; + Sun, 07 Jun 2015 08:12:00 -0700 (PDT) +Received: by 10.129.123.197 with HTTP; Sun, 7 Jun 2015 08:12:00 -0700 (PDT) +Date: Sun, 7 Jun 2015 17:12:00 +0200 +Message-ID: + +Subject: BUG: maildir flags sync with database relative path results in + corrupted filename +From: Morgan Veyret +To: notmuch@notmuchmail.org +Content-Type: multipart/mixed; boundary=001a1149008c6d81e60517eef242 +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.18 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Sun, 07 Jun 2015 15:12:05 -0000 + +--001a1149008c6d81e60517eef242 +Content-Type: multipart/alternative; boundary=001a1149008c6d81df0517eef240 + +--001a1149008c6d81df0517eef240 +Content-Type: text/plain; charset=UTF-8 + +Calling Message.tags_to_maildir_flags() when the database has been opened +with a relative path results in a corrupted filename entry in the database. +The actual filename is changed properly but the filename in the database +gets +the relative path prepended. + +As I understand it's expected that the database path should be absolute but +corrupting the database when the path is relative sounds dangerous. + +Attached is a python script showing the problem. +Run it as follows: + + python ./retag_bug.py db_path +tag,-tag search_query + +Also attached is the output showing the problem. + +--001a1149008c6d81df0517eef240 +Content-Type: text/html; charset=UTF-8 +Content-Transfer-Encoding: quoted-printable + +

= +
Calling Message.tags_to_maildir_flags() when the database ha= +s been opened
with a relative path results in a corrupted filename= + entry in the database.
The actual filename is changed proper= +ly but the filename in the database gets
the relative path pr= +epended.

As I understand it's expected that the datab= +ase path should be absolute but corrupting the database when the path is re= +lative sounds dangerous.

Attached is a python scrip= +t showing the problem.
Run it as follows:

=C2=A0=C2= +=A0 python ./retag_bug.py db_path +tag,-tag search_query

Also = +attached is the output showing the problem.
+

+ +--001a1149008c6d81df0517eef240-- + +--001a1149008c6d81e60517eef242 +Content-Type: text/plain; charset=US-ASCII; name="retag_bug.txt" +Content-Disposition: attachment; filename="retag_bug.txt" +Content-Transfer-Encoding: base64 +X-Attachment-Id: f_iajnwtzj1 + +JCBub3RtdWNoIHNlYXJjaCB0aHJlYWQ6MDAwMDAwMDAwMDAwMDVhMgp0aHJlYWQ6MDAwMDAwMDAw +MDAwMDVhMiAgICAgTWFyY2ggMDcgWzEvMV0gTWF0aGlldSBkZSBWZXJkaWVyZTsgW2ZhYmxhYiBi +cmVzdF0gRWNoYW5nZSBQQyBEVUlOTyBjb250cmUgQVJEVUlOTyBNRUdBK3JhbXA/IChpbmJveCB1 +bnJlYWQpCiQgcHl0aG9uMiAuL3Rlc3QucHkgLi9tYWlsZGlyLyAtdW5yZWFkIHRocmVhZDowMDAw +MDAwMDAwMDAwNWEyIApVc2luZyBkYiBhdCAuL21haWxkaXIvCkNoYW5naW5nIHRhZ3M6IC11bnJl +YWQKU2VhcmNoIHF1ZXJ5OiB0aHJlYWQ6MDAwMDAwMDAwMDAwMDVhMgpBZGRpbmcgdGFnczogW10K +UmVtb3ZpbmcgdGFnczogWyd1bnJlYWQnXQpGaWxlbmFtZTogLi9tYWlsZGlyL2N1ci8xNDI1ODIy +OTkxXzAuMTA3NjQubWludXgsVT0yNjE4LEZNRDU9N2IwZDY2OGUwYjE4ZDg2MDFiOGJjZTRlZWMw +ZWQ5MzA6MiwKUmV0YWdnaW5nIHRocmVhZDowMDAwMDAwMDAwMDAwNWEyCkFkZGluZyBbXQpSZW1v +dmluZyBbJ3VucmVhZCddClN5bmMgbWFpbGRpcjogVHJ1ZQpGb3VuZCAxIG1lc3NhZ2VzIHRvIHJl +dGFnClJldGFnIGRvbmUKRmlsZW5hbWU6IC4vbWFpbGRpci8uL21haWxkaXIvY3VyLzE0MjU4MjI5 +OTFfMC4xMDc2NC5taW51eCxVPTI2MTgsRk1ENT03YjBkNjY4ZTBiMThkODYwMWI4YmNlNGVlYzBl +ZDkzMDoyLFMKCg== +--001a1149008c6d81e60517eef242 +Content-Type: text/x-python; charset=US-ASCII; name="retag_bug.py" +Content-Disposition: attachment; filename="retag_bug.py" +Content-Transfer-Encoding: base64 +X-Attachment-Id: f_iajnwtyj0 + +aW1wb3J0IG5vdG11Y2gKaW1wb3J0IHN5cwoKZGVmIHJldGFnKGRiLHNlYXJjaF9xdWVyeSxhZGRf +bGlzdCxyZW1vdmVfbGlzdCxzeW5jX21haWxkaXIpOgogICAgcXVlcnkgPSBkYi5jcmVhdGVfcXVl +cnkoc2VhcmNoX3F1ZXJ5KQogICAgcHJpbnQgIlJldGFnZ2luZyAlcyIlc2VhcmNoX3F1ZXJ5CiAg +ICBwcmludCAiQWRkaW5nICVzIiVhZGRfbGlzdAogICAgcHJpbnQgIlJlbW92aW5nICVzIiVyZW1v +dmVfbGlzdAogICAgcHJpbnQgIlN5bmMgbWFpbGRpcjogJXMiJXN5bmNfbWFpbGRpcgogICAgdHJ5 +OgogICAgICAgIG1zZ19saXN0ID0gbGlzdChxdWVyeS5zZWFyY2hfbWVzc2FnZXMoKSkKICAgICAg +ICBwcmludCAiRm91bmQgJWQgbWVzc2FnZXMgdG8gcmV0YWciJWxlbihtc2dfbGlzdCkKICAgICAg +ICBkYi5iZWdpbl9hdG9taWMoKQogICAgICAgIGZvciBtc2cgaW4gbXNnX2xpc3Q6CiAgICAgICAg +ICAgIG1zZy5mcmVlemUoKQogICAgICAgICAgICBpZiByZW1vdmVfbGlzdCA9PSBUcnVlOgogICAg +ICAgICAgICAgICAgbXNnLnJlbW92ZV9hbGxfdGFncygpCiAgICAgICAgICAgIGVsc2U6CiAgICAg +ICAgICAgICAgICBmb3IgdCBpbiByZW1vdmVfbGlzdDoKICAgICAgICAgICAgICAgICAgICBtc2cu +cmVtb3ZlX3RhZyh0KQogICAgICAgICAgICBmb3IgdCBpbiBhZGRfbGlzdDoKICAgICAgICAgICAg +ICAgIG1zZy5hZGRfdGFnKHQpCiAgICAgICAgICAgIG1zZy50aGF3KCkKICAgICAgICAgICAgaWYg +c3luY19tYWlsZGlyOgogICAgICAgICAgICAgICAgaWYgbXNnLnRhZ3NfdG9fbWFpbGRpcl9mbGFn +cygpICE9IG5vdG11Y2guU1RBVFVTLlNVQ0NFU1M6CiAgICAgICAgICAgICAgICAgICAgcmFpc2Ug +bm90bXVjaC5Ob3RtdWNoRXJyb3IoKQogICAgICAgIGlmIGRiLmVuZF9hdG9taWMoKSAhPSBub3Rt +dWNoLlNUQVRVUy5TVUNDRVNTOgogICAgICAgICAgICByYWlzZSBub3RtdWNoLk5vdG11Y2hFcnJv +cigpCiAgICAgICAgcHJpbnQgIlJldGFnIGRvbmUiCiAgICBleGNlcHQgbm90bXVjaC5Ob3RtdWNo +RXJyb3IgYXMgZToKICAgICAgICBwcmludCAiRmFpbGVkIHRvIHJldGFnIgogICAgICAgIHByaW50 +IGUKICAgICAgICByZXR1cm4gRmFsc2UKICAgIHJldHVybiBUcnVlCgpkZWYgc2hvd19maWxlbmFt +ZShkYixzZWFyY2hfcXVlcnkpOgogICAgcXVlcnkgPSBk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