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