From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 857546DE17F3 for ; Sun, 12 Mar 2017 05:51:19 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.005 X-Spam-Level: X-Spam-Status: No, score=-0.005 tagged_above=-999 required=5 tests=[AWL=0.006, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01] 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 DDuCm0YyyKL6 for ; Sun, 12 Mar 2017 05:51:18 -0700 (PDT) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by arlo.cworth.org (Postfix) with ESMTPS id 26DC46DE17FE for ; Sun, 12 Mar 2017 05:51:18 -0700 (PDT) Received: from remotemail by fethera.tethera.net with local (Exim 4.84_2) (envelope-from ) id 1cn2xI-0005s7-D9; Sun, 12 Mar 2017 08:50:36 -0400 Received: (nullmailer pid 21705 invoked by uid 1000); Sun, 12 Mar 2017 12:51:16 -0000 From: David Bremner To: Johannes Schauer , notmuch@notmuchmail.org Subject: [PATCH 2/2] lib: clamp return value of g_mime_utils_header_decode_date to >=0 Date: Sun, 12 Mar 2017 09:51:01 -0300 Message-Id: <20170312125101.21656-2-david@tethera.net> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170312125101.21656-1-david@tethera.net> References: <20150422065630.6330.90536@hoothoot> <20170312125101.21656-1-david@tethera.net> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.22 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, 12 Mar 2017 12:51:19 -0000 For reasons not completely understood at this time, gmime (as of 2.6.22) is returning a date before 1900 on bad date input. Since this confuses some other software, we clamp such dates to 0, i.e. 1970-01-01. --- lib/message.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/message.cc b/lib/message.cc index 007f1171..8a8a25b4 100644 --- a/lib/message.cc +++ b/lib/message.cc @@ -1034,10 +1034,15 @@ _notmuch_message_set_header_values (notmuch_message_t *message, /* GMime really doesn't want to see a NULL date, so protect its * sensibilities. */ - if (date == NULL || *date == '\0') + if (date == NULL || *date == '\0') { time_value = 0; - else + } else { time_value = g_mime_utils_header_decode_date (date, NULL); + /* + * Workaround for https://bugzilla.gnome.org/show_bug.cgi?id=779923 + */ + time_value = (time_value < 0) ? 0 : time_value; + } message->doc.add_value (NOTMUCH_VALUE_TIMESTAMP, Xapian::sortable_serialise (time_value)); -- 2.11.0