From patchwork Tue Jan 10 13:19:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frank Lichtenheld X-Patchwork-Id: 2988 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7300:c95:b0:82:e4b3:40a0 with SMTP id p21csp3602924dyk; Tue, 10 Jan 2023 05:20:46 -0800 (PST) X-Google-Smtp-Source: AMrXdXsDHvohT1gQAGZ0DBxVU6uHXLobxQjb24j/mhuWuu/iqB7S8ZftBKIdMjqIJAZQ5lw28dL0 X-Received: by 2002:a17:902:9a0b:b0:189:d3dc:a9c4 with SMTP id v11-20020a1709029a0b00b00189d3dca9c4mr63709514plp.36.1673356846682; Tue, 10 Jan 2023 05:20:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673356846; cv=none; d=google.com; s=arc-20160816; b=vA+9QR13Zm872bffliEpG/UKCIqdbfaBjPs5FGlx+wsqlAuV2jri+5db8NqFidq4PH /NmJuRBxpaqjtCvauVvd6qO6OjQcbdLfQ7YnA7VnZgz5zwHu1Jf8rPV/ABoYDrgk9Lh4 NuC2P+F/M69PHpB9gH0la8Z9KB64xvv3f7nAVKP2UekkKkvIZKg9mJ8a6K9+C1FOu+oZ CZDasCC27TW/5r7jIMriAZQJ+Gf6MpKCdk72x78t5buA7kkc5f55Bt5IrAIroI8L/WQN 1hLb637tWg8MWjiu5u3wGqhsxnac1SzUABD6SgysQHqnQeYkOAeSaTWPGxBXOyBog5QW CzbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:message-id:date:to:from:dkim-signature:dkim-signature; bh=2dRmtH9cB/wA7QwPt4awlCU5zY7xxFWVk+L/sGWS9Ig=; b=KyRk4SIfc9yeVHYgaFyUbp4yadtMo45ZUSWwSTo60Bj73cXkNa4d7+tweXkNZ48yOE hAXtFkc2Vlz34UdvxxPmtfQXrxfHghWPCMssCbveeAwRHdp4pV3kk6vOtH4cEB9Eld9C W/p+ikDTGNKVA/qAvd+QmtSCmrf6O9dlSSMFlhSw5ddZJXXIe/nUXUp3S9z3dhhl2hFr egXdYSFnDTk4sWKND7c+mAvPWRFBMIYPWtcF3QoCQeEGZm0lOJE5dCTswnv3z4NIf+ll fwG4nhrTnv2rsbEPFo2/GcfjWcOcNGIEs7CZTS+6rF7DFPPOOQ8u4YrSV7HqZWifaVZX 3Iqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=DtnC9NDx; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=C3R8fHDb; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id j8-20020a170903024800b0017a034f7246si10903757plh.560.2023.01.10.05.20.46 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Jan 2023 05:20:46 -0800 (PST) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=DtnC9NDx; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=C3R8fHDb; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1pFEYE-0002ya-8a; Tue, 10 Jan 2023 13:20:26 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pFEY0-0002yJ-Cn for openvpn-devel@lists.sourceforge.net; Tue, 10 Jan 2023 13:20:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:Content-Type:MIME-Version :Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=UAA1d9w/0yVFcgL1YOVh+uOp+QCMPwYx70RC59OKwko=; b=DtnC9NDxDxuJrrmci7TxNCFMUa c77XHY1fg4Cjzft4Wtmsg6vSfJ0Lw9dsOfYPfyDK/LGdL6HGcae40D9QG02AoaoJ2QpoZeCcWYbJO hzjTy3RFh4kxZR2p3vYakp5laJW++sPwBwc6nTCmoz0K7D9I+c5xnBY5IlhO9b8GINBM=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-Id:Date: Subject:To:From:Sender:Reply-To:Cc:Content-ID:Content-Description:Resent-Date :Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=UAA1d9w/0yVFcgL1YOVh+uOp+QCMPwYx70RC59OKwko=; b=C 3R8fHDbe4fyme17fZADPtOIQOSi1fYoIGmvury0G0YlMfGhKk+BTzvNfB961BJQHUtbntLdkuxMs4 9hY6H4qwd+ATNCAiNKJfZPSIKne6h3AbB75qbImdaqDL05xm2MWzFf9EGETX2cn6S7WFDsW+A1ta5 yyfOuqGKs0EcuC4k=; Received: from mout-p-102.mailbox.org ([80.241.56.152]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1pFEXq-0001qR-8n for openvpn-devel@lists.sourceforge.net; Tue, 10 Jan 2023 13:20:04 +0000 Received: from smtp1.mailbox.org (smtp1.mailbox.org [10.196.197.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4NrryD5HMdz9spL for ; Tue, 10 Jan 2023 14:19:48 +0100 (CET) From: Frank Lichtenheld To: openvpn-devel@lists.sourceforge.net Date: Tue, 10 Jan 2023 14:19:47 +0100 Message-Id: <20230110131947.59552-1-frank@lichtenheld.com> MIME-Version: 1.0 X-Spam-Score: -0.7 (/) X-Spam-Report: =?unknown-8bit?q?Spam_detection_software=2C_running_on_the_sy?= =?unknown-8bit?q?stem_=22util-spamd-2=2Ev13=2Elw=2Esourceforge=2Ecom=22=2C?= =?unknown-8bit?q?_has_NOT_identified_this_incoming_email_as_spam=2E__The_ori?= =?unknown-8bit?q?ginal?= =?unknown-8bit?q?_message_has_been_attached_to_this_so_you_can_view_it_or_la?= =?unknown-8bit?q?bel?= =?unknown-8bit?q?_similar_future_email=2E__If_you_have_any_questions=2C_see?= =?unknown-8bit?q?_the_administrator_of_that_system_for_details=2E?= =?unknown-8bit?q?_?= =?unknown-8bit?q?_Content_preview=3A__Warning_by_GCC_12=3A_pkcs11=5Fopenssl?= =?unknown-8bit?q?=2Ec=3A237=3A22=3A_warning=3A_dangling?= =?unknown-8bit?b?IHBvaW50ZXIg4oCYdGJz4oCZIHRvIOKAmGVuY+KAmSBtYXkgYmUgdXNl?= =?unknown-8bit?b?ZCBbLVdkYW5nbGluZy1wb2ludGVyPV0gU2lnbmVkLW9mZi1ieTo=?= =?unknown-8bit?q?_Frank_Lichtenheld_=3Cfrank=40lichtenheld=2Ecom=3E_---_src/?= =?unknown-8bit?q?openvpn/pkcs11=5Fopenssl=2Ec?= =?unknown-8bit?q?_=7C_6_+++---_1_file_changed=2C_3_insertions=28+=29=2C_3_de?= =?unknown-8bit?q?letions=28-=29_?= =?unknown-8bit?q?_?= =?unknown-8bit?q?_Content_analysis_details=3A___=28-0=2E7_points=2C_6=2E0_re?= =?unknown-8bit?q?quired=29?= =?unknown-8bit?q?_?= =?unknown-8bit?q?_pts_rule_name______________description?= =?unknown-8bit?q?_----_----------------------_------------------------------?= =?unknown-8bit?q?--------------------?= =?unknown-8bit?q?_-0=2E7_RCVD=5FIN=5FDNSWL=5FLOW______RBL=3A_Sender_listed_a?= =?unknown-8bit?q?t_https=3A//www=2Ednswl=2Eorg/=2C?= =?unknown-8bit?q?_low_trust?= =?unknown-8bit?q?_=5B80=2E241=2E56=2E152_listed_in_list=2Ednswl=2Eorg=5D?= =?unknown-8bit?q?_0=2E0_SPF=5FNONE_______________SPF=3A_sender_does_not_publ?= =?unknown-8bit?q?ish_an_SPF_Record?= =?unknown-8bit?q?_0=2E0_SPF=5FHELO=5FNONE__________SPF=3A_HELO_does_not_publ?= =?unknown-8bit?q?ish_an_SPF_Record?= X-Headers-End: 1pFEXq-0001qR-8n Subject: [Openvpn-devel] [PATCH] xkey_pkcs11h_sign: fix dangling pointer X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: =?utf-8?q?1754641829075662882?= X-GMAIL-MSGID: =?utf-8?q?1754641829075662882?= Warning by GCC 12: pkcs11_openssl.c:237:22: warning: dangling pointer ‘tbs’ to ‘enc’ may be used [-Wdangling-pointer=] Signed-off-by: Frank Lichtenheld Acked-by: Selva Nair --- src/openvpn/pkcs11_openssl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/openvpn/pkcs11_openssl.c b/src/openvpn/pkcs11_openssl.c index 60bc1c47..ecf37ba0 100644 --- a/src/openvpn/pkcs11_openssl.c +++ b/src/openvpn/pkcs11_openssl.c @@ -169,6 +169,9 @@ xkey_pkcs11h_sign(void *handle, unsigned char *sig, unsigned char buf[EVP_MAX_MD_SIZE]; size_t buflen; + unsigned char enc[EVP_MAX_MD_SIZE + 32]; /* 32 bytes enough for DigestInfo header */ + size_t enc_len = sizeof(enc); + if (!strcmp(sigalg.op, "DigestSign")) { msg(D_XKEY, "xkey_pkcs11h_sign: computing digest"); @@ -214,9 +217,6 @@ xkey_pkcs11h_sign(void *handle, unsigned char *sig, { /* CMA_RSA_PKCS needs pkcs1 encoded digest */ - unsigned char enc[EVP_MAX_MD_SIZE + 32]; /* 32 bytes enough for DigestInfo header */ - size_t enc_len = sizeof(enc); - if (!encode_pkcs1(enc, &enc_len, sigalg.mdname, tbs, tbslen)) { return 0;