X-Envelope-From: notmuch-bounces@notmuchmail.org  Mon Aug 10 23:40:36 2026
Return-Path: <notmuch-bounces@notmuchmail.org>
X-Original-To: nmbug@yantan.tethera.net
Delivered-To: nmbug@yantan.tethera.net
Received: from yantan.tethera.net (localhost [127.0.0.1])
	by mail.notmuchmail.org (Postfix) with ESMTP id E9E005F86A;
	Mon, 10 Aug 2026 23:40:35 +0000 (UTC)
Received: from phubs.tethera.net (phubs.tethera.net [192.99.9.157])
	by mail.notmuchmail.org (Postfix) with ESMTPS id 2703D5F5B4
	for <notmuch@notmuchmail.org>; Mon, 10 Aug 2026 23:40:33 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tethera.net;
 i=@tethera.net; q=dns/txt; s=2024; t=1786404782; h=from : to : subject
 : date : message-id : in-reply-to : references : mime-version :
 content-transfer-encoding : from;
 bh=UZ1C11OTtPENsGAceTXJNgMV2voK+DzlQAXQQBNdJW8=;
 b=L5Oe4mMU5994arUWfpJh5QdkLQFvdgbdmy694t4wEYtvio9Htyk2jBC5j720wC/z7Qozx
 mVOyAIZ4fKUzpls/oa3qUC+rOrDytvwkG29TBGEh5eMweuKRv+ndN1L14J2IrMjkDv2MA3X
 BHoyKq31TGywcuKXbEXcmh7w+HH0jIsBCFy3hcTZgHRtkVYNjGJEEEy5EeSnfA5Ig1wQNo1
 aNL9RDHX8hgfwiNzog3N8xmdmEAMwOEZ+GUpk6micXPAfkrFMJRaKPTA0sZ4Pzqx4WraQRL
 gdcUq2QgwouNaHR7qqd7h4tgihFW4uUkTw2yyuhZyELUyp1BafBTqnVAaDFA==
Received: from tethera.net (fctnnbsc38w-142-162-53-181.dhcp-dynamic.fibreop.nb.bellaliant.net [142.162.53.181])
	by phubs.tethera.net (Postfix) with ESMTPS id AE2EB1800FA;
	Mon, 10 Aug 2026 20:33:01 -0300 (ADT)
Received: (nullmailer pid 1965840 invoked by uid 1000);
	Mon, 10 Aug 2026 23:32:53 -0000
From: David Bremner <david@tethera.net>
To: David Bremner <david@tethera.net>, notmuch@notmuchmail.org
Subject: [PATCH 2/3] CLI: avoid creating mime nodes with null 'part' field
Date: Mon, 10 Aug 2026 20:32:35 -0300
Message-ID: <20260810233236.1965808-2-david@tethera.net>
X-Mailer: git-send-email 2.53.0
In-Reply-To: <20260810233236.1965808-1-david@tethera.net>
References: <87o6fe9fsf.fsf@tethera.net>
 <20260810233236.1965808-1-david@tethera.net>
MIME-Version: 1.0
Message-ID-Hash: 6THYYL4H64ZJNIAXJWCW47SDPGVVVWIV
X-Message-ID-Hash: 6THYYL4H64ZJNIAXJWCW47SDPGVVVWIV
X-MailFrom: bremner@tethera.net
X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header
X-Mailman-Version: 3.3.3
Precedence: list
List-Id: "Use and development of the notmuch mail system." <notmuch.notmuchmail.org>
List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
List-Owner: <mailto:notmuch-owner@notmuchmail.org>
List-Post: <mailto:notmuch@notmuchmail.org>
List-Subscribe: <mailto:notmuch-join@notmuchmail.org>
List-Unsubscribe: <mailto:notmuch-leave@notmuchmail.org>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit

Use existing error return values for two functions.

Since everything here is in the CLI, it seems better to print an error
message than silently ignore the error.

It turns out this does not really change the needed mitigation for
[1], but at least we are catching the problem closer to the origin,
and not creating arguably broken internal data structures.

[1] id:20260623074714Z.449345370-stepnem@smrk.net
---
 mime-node.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/mime-node.c b/mime-node.c
index 1c5d619b..6d9c15ac 100644
--- a/mime-node.c
+++ b/mime-node.c
@@ -374,6 +374,11 @@ _mime_node_set_up_part (mime_node_t *node, GMimeObject *part, int numchild)
 	/* Promote part to an envelope and open it */
 	GMimeMessagePart *message_part = GMIME_MESSAGE_PART (part);
 	GMimeMessage *message = g_mime_message_part_get_message (message_part);
+	if (! message) {
+	    fprintf (stderr, "Warning: null message part, ignoring\n");
+	    return false;
+	}
+
 	node->envelope_part = message_part;
 	node->part = GMIME_OBJECT (message);
 	node->nchildren = 1;
@@ -461,6 +466,8 @@ mime_node_child (mime_node_t *parent, int child)
 			g_type_name (G_OBJECT_TYPE (parent->part)));
     }
     node = _mime_node_create (parent, sub, child);
+    if (! node)
+	return NULL;
 
     if (child == parent->next_child && parent->next_part_num != -1) {
 	/* We're traversing in depth-first order.  Record the child's
-- 
2.53.0

_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org
