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 20B1241733A for ; Tue, 27 Apr 2010 16:29:36 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -1.9 X-Spam-Level: X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5 tests=[BAYES_00=-1.9] autolearn=ham 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 NBFCTHlqS053 for ; Tue, 27 Apr 2010 16:29:34 -0700 (PDT) Received: from mail.hohndel.org (mail.hohndel.org [65.23.157.147]) by olra.theworths.org (Postfix) with ESMTP id 3A4AB4196F5 for ; Tue, 27 Apr 2010 16:29:32 -0700 (PDT) Received: by mail.hohndel.org (Postfix, from userid 112) id 6CFDF758001; Tue, 27 Apr 2010 19:29:31 -0400 (EDT) Received: from x200.gr8dns.org (unknown [65.23.157.147]) by mail.hohndel.org (Postfix) with ESMTP id 65004340FA; Tue, 27 Apr 2010 19:29:25 -0400 (EDT) Received: by x200.gr8dns.org (Postfix, from userid 500) id 7D9F7CCD12; Tue, 27 Apr 2010 16:29:25 -0700 (PDT) From: Dirk Hohndel To: Subject: [PATCH 1/2] Fix SEGV in _thread_cleanup_author if author ends with ', ' Date: Tue, 27 Apr 2010 16:29:22 -0700 Message-Id: <1272410963-2106-2-git-send-email-hohndel@infradead.org> X-Mailer: git-send-email 1.6.6.1 In-Reply-To: <1272410963-2106-1-git-send-email-hohndel@infradead.org> References: <1272410963-2106-1-git-send-email-hohndel@infradead.org> 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: Tue, 27 Apr 2010 23:29:36 -0000 Admittedly, an author name ending in ',' guarantees this is spam, and indeed this was triggered by a spam email, but that doesn't mean we shouldn't handle this case correctly. We now check that there is actually a component of the name (presumably the first name) after the comma in the author name. Signed-off-by: Dirk Hohndel --- lib/thread.cc | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/thread.cc b/lib/thread.cc index dc74ee3..13872d4 100644 --- a/lib/thread.cc +++ b/lib/thread.cc @@ -156,11 +156,19 @@ _thread_cleanup_author (notmuch_thread_t *thread, char *blank; int fname,lname; + if (author == NULL) + return NULL; clean_author = talloc_strdup(thread, author); if (clean_author == NULL) return NULL; + /* check if there's a comma in the name and that there's a + * component of the name behind it (so the name doesn't end with + * the comma - in which case the string that strchr finds is just + * one character long ",\0"). + * Otherwise just return the copy of the original author name that + * we just made*/ comma = strchr(author,','); - if (comma) { + if (comma && strlen(comma) > 1) { /* let's assemble what we think is the correct name */ lname = comma - author; fname = strlen(author) - lname - 2; @@ -180,7 +188,6 @@ _thread_cleanup_author (notmuch_thread_t *thread, /* we didn't identify this as part of the email address * so let's punt and return the original author */ strcpy (clean_author, author); - } return clean_author; } -- 1.6.6.1