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 676886DE098B for ; Mon, 16 Oct 2017 08:40:53 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: 0.019 X-Spam-Level: X-Spam-Status: No, score=0.019 tagged_above=-999 required=5 tests=[AWL=0.039, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-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 LEVRNVAg0vR1 for ; Mon, 16 Oct 2017 08:40:52 -0700 (PDT) Received: from mail-lf0-f65.google.com (mail-lf0-f65.google.com [209.85.215.65]) by arlo.cworth.org (Postfix) with ESMTPS id 38DDB6DE01EA for ; Mon, 16 Oct 2017 08:40:52 -0700 (PDT) Received: by mail-lf0-f65.google.com with SMTP id p184so17491880lfe.12 for ; Mon, 16 Oct 2017 08:40:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nikula-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=vp7feFLlq0eX3LWmLEkLAbfUWPRzzUOAei/0/st745U=; b=t/VwDybqpE5GObf2gMRHm8V2Gz3yDimVAZEFZiy/VhxtGBM2s5U5MVL9/gJcuTM/hR Sxs3PrDGMEeDfKKhnTSbPn9p/pd2izW3UsqL/v19MQz+GU8n5ZYQ6ZZqQdBa/OciTU/0 OYTC1DPp4uW7sA6h70zW0CKxbnw1HU161xps+j7HldtHBtM4atCMTToEsxYsHUerSYik Fjegst7uLWHkNtDvlZCuoNEsBE3UfFxZvg5/7tg3ynnezwRJbQvm6+SCc0uhXHaj9Fbi zBkAVEHRLG+sDzYjfR/2ZEwsyzzLzXoezY0xHeeJ+6NgMQn2NM26fhIz9gHf8UW8RaVm APvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=vp7feFLlq0eX3LWmLEkLAbfUWPRzzUOAei/0/st745U=; b=SvzYIaLUh+y2Hs453qa17KKa3a2QI9/GGGYGr7kLiQmSyjl3xudcGVrIojV1i5Q2/N yyUUoDHnCkBr2kWUXplzhEoAFFZErfiFISlURoV8M8dmBoG/jmoImGSiXROJ96OtWGHK 46xQDz8oJ/oAzkTZzGc3ESB6iJAmuFCycP+EBP1z9jx/sAJOuTF6M757Z338OjZFzoS6 0As6SwFzCXm1yFRgzWL7l3PpTORQcUqfa0mxhVy0Q8IDtHDoQa4AFdBP/Vz+8vpxNRl7 kBtwC1Vh8w+uc8XPb7uIRSFEYiMMzIzs8Eo/yh8YXee46JFeSfFo6EjJ26xpGCRdyoyH 7LnA== X-Gm-Message-State: AMCzsaX2aruW9obBuEOImb+Mb2mTt1LiTVzvYTZLTrZg4on64NhydeAf 4/6k/gq9RLsgueG7sTjEraDwuW0AKyc= X-Google-Smtp-Source: ABhQp+R2612iLgBMyeQhmaXImK6a6D219pqsqmaR2HT+mrW64m+Xd+ljj2+dBta5pkSBrNMvVB7ugg== X-Received: by 10.25.215.141 with SMTP id q13mr3335604lfi.6.1508168449685; Mon, 16 Oct 2017 08:40:49 -0700 (PDT) Received: from localhost (mobile-access-5d6a0c-19.dhcp.inet.fi. [93.106.12.19]) by smtp.gmail.com with ESMTPSA id i13sm1566438lfa.44.2017.10.16.08.40.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 08:40:48 -0700 (PDT) From: Jani Nikula To: notmuch@notmuchmail.org Subject: [PATCH] cli/crypto: fix segfault on failed gmime2 crypto context creation Date: Mon, 16 Oct 2017 18:40:44 +0300 Message-Id: <20171016154044.14564-1-jani@nikula.org> X-Mailer: git-send-email 2.11.0 X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.23 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, 16 Oct 2017 15:40:53 -0000 Commit 1fdc08d0ffab ("cli/crypto: treat failure to create a crypto context as fatal.") started treating crypto context creation failures "as fatal", returning NULL from _mime_node_create(). Unfortunately, we do not have NULL checks for _mime_node_create() failures. The only caller, mime_node_child(), could check and return NULL (as it's documented to do on errors) but none of the several call sites have NULL checks either. And none of them really have a trivial but feasible and graceful way of recovery. So while the right thing to do would be to handle NULL returns properly all over the place, and we have other scenarios that do return NULL from above mentioned functions, the crypto context creation failure is something that does seem to show up regularly in some scenarios, revert back to the functionality before commit 1fdc08d0ffab as an interim fix. --- mime-node.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mime-node.c b/mime-node.c index d48be4c46695..27de72fa2f84 100644 --- a/mime-node.c +++ b/mime-node.c @@ -271,7 +271,7 @@ _mime_node_create (mime_node_t *parent, GMimeObject *part) const char *protocol = g_mime_content_type_get_parameter (content_type, "protocol"); cryptoctx = _notmuch_crypto_get_gmime_context (node->ctx->crypto, protocol); if (!cryptoctx) - return NULL; + return node; } #endif -- 2.11.0