{"id":17002,"url":"https://patchwork.libcamera.org/api/1.1/patches/17002/?format=json","web_url":"https://patchwork.libcamera.org/patch/17002/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20220807021456.9578-5-laurent.pinchart@ideasonboard.com>","date":"2022-08-07T02:14:55","name":"[libcamera-devel,4/5] libcamera: pub_key: Gracefully handle failures to load public key","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"7300d5656ebc5edb8d8f6370814cd8413e4a17f2","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/1.1/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/17002/mbox/","series":[{"id":3380,"url":"https://patchwork.libcamera.org/api/1.1/series/3380/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3380","date":"2022-08-07T02:14:51","name":"libcamera: Support openssl as an alternative to gnutls","version":1,"mbox":"https://patchwork.libcamera.org/series/3380/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/17002/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/17002/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 80D63BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun,  7 Aug 2022 02:15:15 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3B05663334;\n\tSun,  7 Aug 2022 04:15:15 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 189C063330\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun,  7 Aug 2022 04:15:11 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id A5C3C749\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun,  7 Aug 2022 04:15:10 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1659838515;\n\tbh=VieJwiGRICkhDuun+18JfNtghQfNkU4dOuNkXashPhM=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=OTcNnhYBNexNk1URqO4NGgFWP9VFBJZ9I0FPKFVvE9mAR9lDewD4NyGcG6xDo7cEN\n\t7I0ALnbctOEH/nReQnfs8c3ZeINIBZlJ/tjGyEaYZtI8bW4uVvQv3Xp8Dha6v09eZq\n\t7eLWj3LZTlpcxIX3cr8uTnBNK75SCcGJzqbTE1IMzu3ATl/Yf9uwrEcXui2fHfJ0Yo\n\tR4bcEmvR9eto04IoD6RCK32+1OFR5xmbVOWO3VD6TIzwIVCyAisUQy+lV/mGepxDOC\n\twjsdWqo13ssOhocMvF3QS0Rrp5O04DBB6KvuPZ6XyZRhIiuM9REzdrLzTBgDT7fDIU\n\tEZyNHwNzZs2oA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1659838510;\n\tbh=VieJwiGRICkhDuun+18JfNtghQfNkU4dOuNkXashPhM=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=ZbTIbCaVsS98Kxl10wPRuko2/bTClp7SfsIy5xDwIK4uLjngb/dUq/ac2PnjWrBM7\n\t26qocfWglXCVnZi/fyN6BAIak6y0pyb/mhYkmV0dUd3uOYZOMLhk0iadeQZ0EWtJUv\n\ttnG/8VbQPb9EKAYFn+9XM1aWTTWfu9PozLNPzJA0="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"ZbTIbCaV\"; dkim-atps=neutral","To":"libcamera-devel@lists.libcamera.org","Date":"Sun,  7 Aug 2022 05:14:55 +0300","Message-Id":"<20220807021456.9578-5-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.35.1","In-Reply-To":"<20220807021456.9578-1-laurent.pinchart@ideasonboard.com>","References":"<20220807021456.9578-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 4/5] libcamera: pub_key: Gracefully handle\n\tfailures to load public key","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"If the public key fails to load, PubKey::isValid() function returns\nfalse. The only user of the PubKey class, the IPAManager class, doesn't\ncheck that condition, and still calls the PubKey::verify() function,\nwhich leads to a crash.\n\nFix this by returning false from PubKey::verify() if the key isn't\nvalid, and log a warning in the IPAManager constructor to report the\nissue.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/ipa_manager.cpp | 3 +++\n src/libcamera/pub_key.cpp     | 3 +++\n 2 files changed, 6 insertions(+)","diff":"diff --git a/src/libcamera/ipa_manager.cpp b/src/libcamera/ipa_manager.cpp\nindex ec9660456960..2f96a2072fd6 100644\n--- a/src/libcamera/ipa_manager.cpp\n+++ b/src/libcamera/ipa_manager.cpp\n@@ -109,6 +109,9 @@ IPAManager::IPAManager()\n \t\tLOG(IPAManager, Fatal)\n \t\t\t<< \"Multiple IPAManager objects are not allowed\";\n \n+\tif (!pubKey_.isValid())\n+\t\tLOG(IPAManager, Warning) << \"Public key not valid\";\n+\n \tunsigned int ipaCount = 0;\n \n \t/* User-specified paths take precedence. */\ndiff --git a/src/libcamera/pub_key.cpp b/src/libcamera/pub_key.cpp\nindex 9bb08fda34af..b2045a103bc0 100644\n--- a/src/libcamera/pub_key.cpp\n+++ b/src/libcamera/pub_key.cpp\n@@ -76,6 +76,9 @@ PubKey::~PubKey()\n bool PubKey::verify([[maybe_unused]] Span<const uint8_t> data,\n \t\t    [[maybe_unused]] Span<const uint8_t> sig) const\n {\n+\tif (!valid_)\n+\t\treturn false;\n+\n #if HAVE_GNUTLS\n \tconst gnutls_datum_t gnuTlsData{\n \t\tconst_cast<unsigned char *>(data.data()),\n","prefixes":["libcamera-devel","4/5"]}