[PATCH 03/11] lib: Handle empty date value
authorAustin Clements <aclements@csail.mit.edu>
Fri, 3 Oct 2014 14:19:10 +0000 (10:19 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 18:04:54 +0000 (10:04 -0800)
04/34ea729c8f595f179257873ecf35122140319f [new file with mode: 0644]

diff --git a/04/34ea729c8f595f179257873ecf35122140319f b/04/34ea729c8f595f179257873ecf35122140319f
new file mode 100644 (file)
index 0000000..54adc2b
--- /dev/null
@@ -0,0 +1,102 @@
+Return-Path: <aclements@csail.mit.edu>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 2BFCF431FDC\r
+       for <notmuch@notmuchmail.org>; Fri,  3 Oct 2014 07:20:16 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -2.3\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id cqXcrULdslkl for <notmuch@notmuchmail.org>;\r
+       Fri,  3 Oct 2014 07:20:08 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-3.mit.edu (dmz-mailsec-scanner-3.mit.edu\r
+       [18.9.25.14])\r
+       (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 10E60431FDD\r
+       for <notmuch@notmuchmail.org>; Fri,  3 Oct 2014 07:19:35 -0700 (PDT)\r
+X-AuditID: 1209190e-f79d46d000003643-30-542eb076825d\r
+Received: from mailhub-auth-3.mit.edu ( [18.9.21.43])\r
+       (using TLS with cipher AES256-SHA (256/256 bits))\r
+       (Client did not present a certificate)\r
+       by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP\r
+       id B2.C6.13891.670BE245; Fri,  3 Oct 2014 10:19:34 -0400 (EDT)\r
+Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])\r
+       by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id s93EJNM9018547; \r
+       Fri, 3 Oct 2014 10:19:24 -0400\r
+Received: from drake.dyndns.org\r
+       (216-15-114-40.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com\r
+       [216.15.114.40]) (authenticated bits=0)\r
+       (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+       by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id s93EJLxD023310\r
+       (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT);\r
+       Fri, 3 Oct 2014 10:19:23 -0400\r
+Received: from amthrax by drake.dyndns.org with local (Exim 4.84)\r
+       (envelope-from <aclements@csail.mit.edu>)\r
+       id 1Xa3hZ-0002Jh-2r; Fri, 03 Oct 2014 10:19:21 -0400\r
+From: Austin Clements <aclements@csail.mit.edu>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 03/11] lib: Handle empty date value\r
+Date: Fri,  3 Oct 2014 10:19:10 -0400\r
+Message-Id: <1412345958-8278-4-git-send-email-aclements@csail.mit.edu>\r
+X-Mailer: git-send-email 2.1.0\r
+In-Reply-To: <1412345958-8278-1-git-send-email-aclements@csail.mit.edu>\r
+References: <1412345958-8278-1-git-send-email-aclements@csail.mit.edu>\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFtrPIsWRmVeSWpSXmKPExsUixCmqrVu2QS/EoGuzhMX1mzOZHRg9nq26\r
+       xRzAGMVlk5Kak1mWWqRvl8CVsXPVF7aCjawVjy8eY2pgXM7SxcjJISFgInFxbz8jhC0mceHe\r
+       erYuRi4OIYHZTBIdlxYyQTgbGCVWvm6Ecm4zSezdc5kdwlnCKPGv/x9YP5uAvsSKtZNYQWwR\r
+       AWmJnXdnA9kcHMwCahJ/ulRAwsICxhIPT2wCK2ERUJXYc+EMG4jNK+Am0fZ8NjPEGXISG3b/\r
+       BxvJKeAuceHuU7AaIaCaVce62SYw8i9gZFjFKJuSW6Wbm5iZU5yarFucnJiXl1qka6yXm1mi\r
+       l5pSuokRHDaSfDsYvx5UOsQowMGoxMP74YZuiBBrYllxZe4hRkkOJiVR3srFeiFCfEn5KZUZ\r
+       icUZ8UWlOanFhxglOJiVRHgXrATK8aYkVlalFuXDpKQ5WJTEeTf94AsREkhPLEnNTk0tSC2C\r
+       ycpwcChJ8LavB2oULEpNT61Iy8wpQUgzcXCCDOcBGg5Ww1tckJhbnJkOkT/FqMvR0vS2l0mI\r
+       JS8/L1VKnPfhOqAiAZCijNI8uDmweH/FKA70ljBvF8goHmCqgJv0CmgJE9CSd/a6IEtKEhFS\r
+       Ug2MMqHnPh39pTH99f6NyppyPyyZ+Bs232b7fjx0t7LDbz0bIf7tRyxPH+TkvWl5wyz10M7D\r
+       t8qahK9Idq2LeWO4Oys5i//dim9mb8J0lJpzO//+Pv7sWuHP8lP1hzhedfEo+sx+LbHjdHZh\r
+       y7Ww0GLRxPXKWV0Z5m6HUo+5bZJ+/5TTVYmx7kyTEktxRqKhFnNRcSIA/nB3JNICAAA=\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Fri, 03 Oct 2014 14:20:16 -0000\r
+\r
+From: Austin Clements <amdragon@mit.edu>\r
+\r
+In the interest of robustness, avoid undefined behavior of\r
+sortable_unserialise if the date value is missing.  This shouldn't\r
+happen now, but ghost messages will have blank date values.\r
+---\r
+ lib/message.cc | 3 +++\r
+ 1 file changed, 3 insertions(+)\r
+\r
+diff --git a/lib/message.cc b/lib/message.cc\r
+index bbfc250..38bc929 100644\r
+--- a/lib/message.cc\r
++++ b/lib/message.cc\r
+@@ -896,6 +896,9 @@ notmuch_message_get_date (notmuch_message_t *message)\r
+       return 0;\r
+     }\r
\r
++    if (value.empty ())\r
++      /* sortable_unserialise is undefined on empty string */\r
++      return 0;\r
+     return Xapian::sortable_unserialise (value);\r
+ }\r
\r
+-- \r
+2.1.0\r
+\r