From 85eb1e7ac745e5418a53734a2d905f3b1e96b3eb Mon Sep 17 00:00:00 2001 From: Sascha Silbe Date: Sun, 24 Jun 2012 18:29:24 +0200 Subject: [PATCH] [PATCH 1/3] lib: fix NULL checks for filenames iterators --- d8/7e8cc6f0f6ffdbae0ee1a560a8a8de38e9d229 | 87 +++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 d8/7e8cc6f0f6ffdbae0ee1a560a8a8de38e9d229 diff --git a/d8/7e8cc6f0f6ffdbae0ee1a560a8a8de38e9d229 b/d8/7e8cc6f0f6ffdbae0ee1a560a8a8de38e9d229 new file mode 100644 index 000000000..808a469ec --- /dev/null +++ b/d8/7e8cc6f0f6ffdbae0ee1a560a8a8de38e9d229 @@ -0,0 +1,87 @@ +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 934D1431FC0 + for ; Sun, 24 Jun 2012 09:29:45 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] + 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 F+bo1y+H2uwo for ; + Sun, 24 Jun 2012 09:29:45 -0700 (PDT) +Received: from smtp.chost.de (setoy.chost.de [217.160.209.225]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 62AFA431FAF + for ; Sun, 24 Jun 2012 09:29:44 -0700 (PDT) +Received: (qmail 14465 invoked by uid 5015); 24 Jun 2012 16:29:41 -0000 +Received: (nullmailer pid 3421 invoked by uid 123); + Sun, 24 Jun 2012 16:29:39 -0000 +Received: from twin.sascha.silbe.org (twin.sascha.silbe.org [192.168.1.2]) + by flatty.sascha.silbe.org ([192.168.1.252]) + with SMTP via TCP; 24 Jun 2012 16:29:39 -0000 +Received: (nullmailer pid 25946 invoked by uid 8193); + Sun, 24 Jun 2012 16:29:39 -0000 +From: Sascha Silbe +To: notmuch +Subject: [PATCH 1/3] lib: fix NULL checks for filenames iterators +Date: Sun, 24 Jun 2012 18:29:24 +0200 +Message-Id: <1340555366-25891-2-git-send-email-sascha-pgp@silbe.org> +X-Mailer: git-send-email 1.7.10 +In-Reply-To: <1340555366-25891-1-git-send-email-sascha-pgp@silbe.org> +References: <1340555366-25891-1-git-send-email-sascha-pgp@silbe.org> +Mail-Followup-To: notmuch +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +Reply-To: Sascha Silbe +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, 24 Jun 2012 16:29:46 -0000 + +The API documentation (notmuch.h) states that the parameter may be NULL, +but the implementation only checked the current element, potentially +dereferencing a NULL pointer in the process. + +Signed-off-by: Sascha Silbe +--- + lib/filenames.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/lib/filenames.c b/lib/filenames.c +index f1ea243..4f7c0d8 100644 +--- a/lib/filenames.c ++++ b/lib/filenames.c +@@ -54,7 +54,7 @@ notmuch_filenames_valid (notmuch_filenames_t *filenames) + const char * + notmuch_filenames_get (notmuch_filenames_t *filenames) + { +- if (filenames->iterator == NULL) ++ if ((filenames == NULL) || (filenames->iterator == NULL)) + return NULL; + + return filenames->iterator->string; +@@ -63,7 +63,7 @@ notmuch_filenames_get (notmuch_filenames_t *filenames) + void + notmuch_filenames_move_to_next (notmuch_filenames_t *filenames) + { +- if (filenames->iterator == NULL) ++ if ((filenames == NULL) || (filenames->iterator == NULL)) + return; + + filenames->iterator = filenames->iterator->next; +-- +1.7.10 + -- 2.26.2