From 12c07c19e4e3c2fcc6ac7233a3dd49f4a7fa6074 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Tue, 7 Oct 2014 17:17:09 +1800 Subject: [PATCH] [PATCH v2 03/12] lib: Handle empty date value --- 20/6581131a6a21c9b4f7bf5689f04b19c4b62e2c | 101 ++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 20/6581131a6a21c9b4f7bf5689f04b19c4b62e2c diff --git a/20/6581131a6a21c9b4f7bf5689f04b19c4b62e2c b/20/6581131a6a21c9b4f7bf5689f04b19c4b62e2c new file mode 100644 index 000000000..51eb10caa --- /dev/null +++ b/20/6581131a6a21c9b4f7bf5689f04b19c4b62e2c @@ -0,0 +1,101 @@ +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 255A8431FD5 + for ; Mon, 6 Oct 2014 16:18:04 -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 8nIfRIr8zn3I for ; + Mon, 6 Oct 2014 16:18:00 -0700 (PDT) +Received: from dmz-mailsec-scanner-1.mit.edu (dmz-mailsec-scanner-1.mit.edu + [18.9.25.12]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id C7E8F431FB6 + for ; Mon, 6 Oct 2014 16:17:36 -0700 (PDT) +X-AuditID: 1209190c-f795e6d000006c66-2a-54332310faa0 +Received: from mailhub-auth-4.mit.edu ( [18.7.62.39]) + (using TLS with cipher AES256-SHA (256/256 bits)) + (Client did not present a certificate) + by dmz-mailsec-scanner-1.mit.edu (Symantec Messaging Gateway) with SMTP + id 39.75.27750.01323345; Mon, 6 Oct 2014 19:17:36 -0400 (EDT) +Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11]) + by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id s96NHPCV032087; + Mon, 6 Oct 2014 19:17:25 -0400 +Received: from drake.dyndns.org ([12.185.136.2]) (authenticated bits=0) + (User authenticated as amdragon@ATHENA.MIT.EDU) + by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id s96NHMLY014470 + (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT); + Mon, 6 Oct 2014 19:17:24 -0400 +Received: from amthrax by drake.dyndns.org with local (Exim 4.84) + (envelope-from ) + id 1XbHWr-0001JQ-NV; Mon, 06 Oct 2014 17:17:21 -0600 +From: Austin Clements +To: notmuch@notmuchmail.org +Subject: [PATCH v2 03/12] lib: Handle empty date value +Date: Mon, 6 Oct 2014 17:17:09 -0600 +Message-Id: <1412637438-4821-4-git-send-email-aclements@csail.mit.edu> +X-Mailer: git-send-email 2.1.0 +In-Reply-To: <1412637438-4821-1-git-send-email-aclements@csail.mit.edu> +References: <1412637438-4821-1-git-send-email-aclements@csail.mit.edu> +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFjrJIsWRmVeSWpSXmKPExsUixG6nriugbBxi8GcXr8WN1m5Gi+s3ZzI7 + MHk8W3WL2WPLoffMAUxRXDYpqTmZZalF+nYJXBk7V31hK9jIWvH44jGmBsblLF2MnBwSAiYS + d6+3sULYYhIX7q1n62Lk4hASmM0ksefBVSYIZwOjxP5Z+6AyS5kkel/+ZgdpERJYwiixtCUO + xGYT0JdYsXYS2CgRAWmJnXdng9nMApYSV7+2M4HYwgJmErdfr2QDsVkEVCV2/vnFDGLzCrhJ + 3D4zgw3iDDmJDbv/M4LYnALuEmuuTGaF2OUm8fznU5YJjPwLGBlWMcqm5Fbp5iZm5hSnJusW + Jyfm5aUW6Rrq5WaW6KWmlG5iBIUSpyTPDsY3B5UOMQpwMCrx8EbsMAwRYk0sK67MPcQoycGk + JMo7h904RIgvKT+lMiOxOCO+qDQntfgQowQHs5IIL9dvoxAh3pTEyqrUonyYlDQHi5I476Yf + fCFCAumJJanZqakFqUUwWRkODiUJ3t+KQEMFi1LTUyvSMnNKENJMHJwgw3mAhv8DqeEtLkjM + Lc5Mh8ifYtTlaGl628skxJKXn5cqJc4bDFIkAFKUUZoHNweWAl4xigO9JcwrrgRUxQNMH3CT + XgEtYQJaYjpHH2RJSSJCSqqBMbVf6Dabz0oXyQuFtzIyXp9LWJgneX12r9PvnKc8MhmMCy4H + 1ioLPpxUPbFzTpyW0eULbPzMxg/nnpvy/5JGzPu1ond/OelwhSTs8dv6ca7j07iTnx4/0vBy + 1rZcbKLpulP5t1RkaEqX1qHgqb9a5ew677Ie8H38RuShNuPjk9NL7ir8uzdBWomlOCPRUIu5 + qDgRABEbw9HcAgAA +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: Mon, 06 Oct 2014 23:18:04 -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 + -- 2.26.2