From patchwork Thu Apr 17 13:46:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 4223 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7001:fcb:b0:63e:cbae:3930 with SMTP id yu11csp634197mab; Thu, 17 Apr 2025 06:47:14 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUcf2kHw7Oz62GKFfjTCs5AL25iVaViGPvTmKN7UJmijHrGiN81+YvI64Ic6xZGu8AEXC9hUVi0Lcw=@openvpn.net X-Google-Smtp-Source: AGHT+IHmpxkT49EyI0qZLxwQ6nA69km6r5J9LAbsLSjWmWhXaZU1FLdd2XINeeTA7yEZ/MsUt744 X-Received: by 2002:a05:6871:e70b:b0:2c7:7317:c847 with SMTP id 586e51a60fabf-2d4d2d05bb3mr3743360fac.33.1744897634167; Thu, 17 Apr 2025 06:47:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1744897634; cv=none; d=google.com; s=arc-20240605; b=VlIzLvqd0cZP6O9kSjAf2KuNJJ07iCvRYbLI+y+zQi69y7Jd9ZrugP9SkyIgiBBiVZ TftazV15Ejw5kZBbksTQVLK4iB56ggJvW5mb3WNNiX3XN1U6qX0BPgIGrK9OOnCJcBjx CntLcLiarO4fH4dkcJsyBidPzRaUmEaXzONqXbRiupoOTtgPH32AJQFdBXV3YzV0flYv a0AS4NEgXmsPmyJ4kXaTGsKakskWO5u3ye84IyPwcWV1l0wbNXmAt0i7v8JrVGRdUcbI isT7dqujiQ1NUVPx5VKPbSxxz5JyA24PauRej/dNUnRVYCPX++OMzdJsFejpxBg1veB+ 5+vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:dkim-signature; bh=SjVvFGd0gRIs2J/XFnc/CCVRlIk+tHu088J+dw8zQhg=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=O6kzUowPoqX8zoeh4VpoQk9abk4etK8zM174aIUx41xHmIaAsFpesrQ/STjgXX5SG2 OocUdF3w8XHH4grIBdOaXlUYsonvDiviGpE51huZldkhX2HRhAi8+qBPw/H+dgbmrfc7 GSHvXBGiya1wja0Nbp5bK947WYW3JBPrrdz2fSPvTjMkUYM15Jop+C4m0ipIRCPI5TcM 6oy1kUB9O/HnSYzMSO7ymIDCWG+885lpWbm+P1sx6lSkXPhCFOvAe15YiEj/hmeelEDk WAo+I00+UeqB/SDbb/Fvcx6aYCeRKoAbTDCnBpuh2e9zkwCjtMnGgGjak6SM8ZDRVSdf ddbg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b="J/x+96GW"; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=OsGXj7Ru; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id 586e51a60fabf-2d096e07920si10301325fac.226.2025.04.17.06.47.13 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Apr 2025 06:47:13 -0700 (PDT) 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="J/x+96GW"; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=OsGXj7Ru; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1u5Pa6-0001w8-SU; Thu, 17 Apr 2025 13:47:07 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1u5Pa5-0001w1-3h for openvpn-devel@lists.sourceforge.net; Thu, 17 Apr 2025 13:47:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=GB5gwHNQSYFp2O12/ScZ74s2b2MED7qgJD0EbAejjso=; b=J/x+96GWLWdfKDV570jlgb/kpR KZ+3JatJatCNSiyuOpGtcvSgJ42/0ea6VljP+sJk0e2d7h77T6lYVHAZJjJoiHlYnzTolcAbWQl/Y kQGFAfOC3yuWNdVrfW79UBIXbjHES30KQ6ZtSG1ombdkUOho2WsiL+nCwdmy66upJtJY=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=GB5gwHNQSYFp2O12/ScZ74s2b2MED7qgJD0EbAejjso=; b=OsGXj7Ru8sJEuhuxF8LL5LQSDa rzFLR12slq4xKqd9M6K8MSmx6q75NI+KZasbNHWtrykAo+cjBvdktxftts4OLJ594kErqwBYR93sY NEZfFmszzLYH+sUiVy1VFj1MJ1knju79Lb+ls8A8iWWMYZV0zGq24RvK0T94gZDAZCC4=; Received: from [193.149.48.143] (helo=blue.greenie.muc.de) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1u5PZo-0007DU-LJ for openvpn-devel@lists.sourceforge.net; Thu, 17 Apr 2025 13:47:05 +0000 Received: from blue.greenie.muc.de (localhost [127.0.0.1]) by blue.greenie.muc.de (8.17.1.9/8.17.1.9) with ESMTP id 53HDkaVS021311 for ; Thu, 17 Apr 2025 15:46:36 +0200 Received: (from gert@localhost) by blue.greenie.muc.de (8.17.1.9/8.17.1.9/Submit) id 53HDkaMT021310 for openvpn-devel@lists.sourceforge.net; Thu, 17 Apr 2025 15:46:36 +0200 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Thu, 17 Apr 2025 15:46:30 +0200 Message-ID: <20250417134636.21279-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.49.0 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Score: 1.7 (+) X-Spam-Report: Spam detection software, running on the system "util-spamd-2.v13.lw.sourceforge.com", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Lev Stipakov Fixes a potential double-free issue in tls_ctx_load_cert_uri() by explicitly nullifying the pointer immediately after calling OSSL_STORE_INFO_free(info). This ensures that subsequent cleanup won't attempt to free the same pointer again. Content analysis details: (1.7 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [URIs: openvpn.net] 0.0 RCVD_IN_VALIDITY_SAFE_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [193.149.48.143 listed in sa-accredit.habeas.com] 0.0 RCVD_IN_VALIDITY_RPBL_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [193.149.48.143 listed in bl.score.senderscore.com] 0.4 NO_DNS_FOR_FROM DNS: Envelope sender has no MX or A DNS records 0.0 SPF_HELO_FAIL SPF: HELO does not match SPF record (fail) [SPF failed: Rejected by SPF record] 0.0 SPF_NONE SPF: sender does not publish an SPF Record 1.3 RDNS_NONE Delivered to internal network by a host with no rDNS X-Headers-End: 1u5PZo-0007DU-LJ Subject: [Openvpn-devel] [PATCH v4] ssl_openssl.c: Prevent potential double-free 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?1829657781783952115?= X-GMAIL-MSGID: =?utf-8?q?1829657781783952115?= From: Lev Stipakov Fixes a potential double-free issue in tls_ctx_load_cert_uri() by explicitly nullifying the pointer immediately after calling OSSL_STORE_INFO_free(info). This ensures that subsequent cleanup won't attempt to free the same pointer again. GitHub: #726 Change-Id: I4507be07cd5573b2117e837ef03187535a38a4b1 Signed-off-by: Lev Stipakov Acked-by: Antonio Quartulli --- This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master. Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/942 This mail reflects revision 4 of this Change. Acked-by according to Gerrit (reflected above): Antonio Quartulli diff --git a/src/openvpn/ssl_openssl.c b/src/openvpn/ssl_openssl.c index d1d5d3e..f7be50c 100644 --- a/src/openvpn/ssl_openssl.c +++ b/src/openvpn/ssl_openssl.c @@ -1152,6 +1152,7 @@ goto end; } OSSL_STORE_INFO_free(info); + info = NULL; /* iterate through the store and add extra certificates if any to the chain */ while (!OSSL_STORE_eof(store_ctx)) @@ -1170,6 +1171,7 @@ break; } OSSL_STORE_INFO_free(info); + info = NULL; } end: