From patchwork Mon May 15 15:53:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Lichtenheld X-Patchwork-Id: 3214 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7300:7b9a:b0:c3:1364:a2a2 with SMTP id j26csp6879624dyk; Mon, 15 May 2023 08:54:26 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ52C+tBTmMC3T765sgvwTyaSgV3/XAYnXygMKap1FREs5pCJxrRcj1CzP5Zy+q4TIhv02xj X-Received: by 2002:a92:c6d2:0:b0:335:7fb1:bb44 with SMTP id v18-20020a92c6d2000000b003357fb1bb44mr16816502ilm.12.1684166065803; Mon, 15 May 2023 08:54:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684166065; cv=none; d=google.com; s=arc-20160816; b=ljqN9lrjmDNwHsMRNR5gRlyyFTv3gmSK1ftyLUwCdO7BQFqWlOT44Q67Czl/HhP7HY 9KBfQMvp8yhF0MwAsvpJoQceaCOjuyO2i9p8WeHsUYIKB1BBrTPEFVXDyuFla0UXwWq+ QJMIgpwfAAgPnE7zifKJeQXqMk1eaofyMHum7Vv58Qg/DKY/p/zGdeH7lVV7iOG1VbPL K5bo5yd1JiRVYIvmMOY0ImoGBlZJNmcQWxF/lOR2sHUSfIIJ1cd82opNqkTsgaAjOoIo wq/+I3V+sqQ2E+CHepB/KI1EB2eKZ/VJqTtwHyKyklGdiOOfclx+WS/2fwoGuL+R/18j YtAQ== 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 :dkim-signature; bh=/mwlM+EUCmulQeXx4rITkDuhEprhcG/Bcrc9GroB60k=; b=N8zNiBwM0VQrk/5aSwC6iNuBHBTo8UWUGDxutFiA8iJutIl3fxJI9E4HVIyLtfVlYh 2G7G9RV9moHI2txZYKoULQIblF4wimVSfyhzfHYg+782TjYNUFlYKdPvYC2D17q891h+ FfWLkakFTDj9hTYFt4esNJD2T36pLb0pzK8dKA3Hf3EHzaP4Un0+gmLfylSlEHqgLnN+ NI9WnyYprcdRvoyTiyNPlsjAlz7VpNjiMZ4VdKtRJ2DruJNXGHpSlJSb9Xeqq4JuztpO mAE1wEDgdLnyBUwpX4We6sLMHOE2RrnMWok0dr1m5tpTZUGHTF0duKwIrvTBWRQJXoOU /qoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=MaHIEbxx; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b="Mdj/5UgC"; dkim=neutral (body hash did not verify) header.i=@lichtenheld.com header.s=MBO0001 header.b=NY64zGWX; 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 1-20020a021101000000b0041455359407si11032270jaf.120.2023.05.15.08.54.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 May 2023 08:54:25 -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=MaHIEbxx; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b="Mdj/5UgC"; dkim=neutral (body hash did not verify) header.i=@lichtenheld.com header.s=MBO0001 header.b=NY64zGWX; 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-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1pyaWK-0002KD-LT; Mon, 15 May 2023 15:53:57 +0000 Received: from [172.30.20.202] (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 1pyaWI-0002K2-FQ for openvpn-devel@lists.sourceforge.net; Mon, 15 May 2023 15:53:55 +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: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:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=YadK4eFJt9SLJSOe+Zn9w5vTGRE5GBloPEHTRmSPwbE=; b=MaHIEbxxdrZagrCeQGxCOBdpz4 7r8Y+l8lON6zEWHFHz1TtHqogl5HcAYFpA+IuqhSOBag+Z7OBwvLCzGhm9FpsfEbpX8fTxtzS1rni XR2M19QoEENnNl6PJWl+Rj7hfGPLWM1L9dAXuWEtKjGnVgkGscovMe4gz1Lrt4N+mYqM=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version: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:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=YadK4eFJt9SLJSOe+Zn9w5vTGRE5GBloPEHTRmSPwbE=; b=M dj/5UgCFzLa2tpAhqOOSmxyzb2EZA+6h9TnZb8O4sCUOC2PuzzBPTrLK7ag6bziFlNrVARkIT6DlP M3aXBeWcPLrlV6bdk+Cfpl3eblF+dlcX22mJovW5O1U949GRgcdPvpSKx55wGAnTai7aSRqTdf3ka wzm0vzbrsOzbz6KI=; Received: from mout-p-202.mailbox.org ([80.241.56.172]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1pyaWG-00022K-0k for openvpn-devel@lists.sourceforge.net; Mon, 15 May 2023 15:53:55 +0000 Received: from smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (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-202.mailbox.org (Postfix) with ESMTPS id 4QKkS42xP6z9sVw for ; Mon, 15 May 2023 17:53:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lichtenheld.com; s=MBO0001; t=1684166020; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=YadK4eFJt9SLJSOe+Zn9w5vTGRE5GBloPEHTRmSPwbE=; b=NY64zGWXIT3eQ9HM1QZY7jE88sXiiW+9UdqNWgTVwpLG7KJi1pLxs9DZLFQ7IVN2X6P+YT JYgkOQ2SQ5buJ3bSoZkXQ2548Bv0mg/TNckI9Qty7xvIWd7XWL/LNw++SD/X0+FJgG/g6l LA8HVaIw97EPppxwPmjlSSaECOola5cNTZFOl63ns95T3shIn9zd+tFxmYX6Xqvhxv8Rlp Nx6fbZHxRzylO1DjB6bj2qJT+ct3TZXws3rl5Za+eXXoTWpbPqsd6blo9F6VEVhBhBCuoj 4QSc60kBzqmKPJlc+aLoJrXxIDKyVU0cECOheQsoIatPocky/W0+2xeZXAyThw== From: Frank Lichtenheld To: openvpn-devel@lists.sourceforge.net Date: Mon, 15 May 2023 17:53:39 +0200 Message-Id: <20230515155339.38600-1-frank@lichtenheld.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 4QKkS42xP6z9sVw X-Spam-Score: -0.9 (/) X-Spam-Report: Spam detection software, running on the system "util-spamd-1.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: I was looking for memleaks in the code and found this one with cppcheck. Only an example, but no need to leave this bug in it. Also fix fortify problem in keying-material-exporter-demo so I can actually test the compilation of the sample plugins. Content analysis details: (-0.9 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [80.241.56.172 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-Headers-End: 1pyaWG-00022K-0k Subject: [Openvpn-devel] [PATCH] sample-plugins: Fix memleak in client-connect example plugin 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?1765976116540822797?= X-GMAIL-MSGID: =?utf-8?q?1765976116540822797?= I was looking for memleaks in the code and found this one with cppcheck. Only an example, but no need to leave this bug in it. Also fix fortify problem in keying-material-exporter-demo so I can actually test the compilation of the sample plugins. Change-Id: Ibd1b282afc4a28768be3f165f84ab60ca4d24a9b Signed-off-by: Frank Lichtenheld --- .../sample-plugins/client-connect/sample-client-connect.c | 6 ++++++ .../keying-material-exporter-demo/keyingmaterialexporter.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/sample/sample-plugins/client-connect/sample-client-connect.c b/sample/sample-plugins/client-connect/sample-client-connect.c index 391de344..eb242126 100644 --- a/sample/sample-plugins/client-connect/sample-client-connect.c +++ b/sample/sample-plugins/client-connect/sample-client-connect.c @@ -454,6 +454,9 @@ openvpn_plugin_client_connect_v2(struct plugin_context *context, if (!rl->name || !rl->value) { plugin_log(PLOG_ERR, MODULE, "malloc(return_list->xx) failed"); + free(rl->name); + free(rl->value); + free(rl); return OPENVPN_PLUGIN_FUNC_ERROR; } @@ -509,6 +512,9 @@ openvpn_plugin_client_connect_defer_v2(struct plugin_context *context, if (!rl->name || !rl->value) { plugin_log(PLOG_ERR, MODULE, "malloc(return_list->xx) failed"); + free(rl->name); + free(rl->value); + free(rl); return OPENVPN_PLUGIN_FUNC_ERROR; } diff --git a/sample/sample-plugins/keying-material-exporter-demo/keyingmaterialexporter.c b/sample/sample-plugins/keying-material-exporter-demo/keyingmaterialexporter.c index 6a0a1f69..f84cf232 100644 --- a/sample/sample-plugins/keying-material-exporter-demo/keyingmaterialexporter.c +++ b/sample/sample-plugins/keying-material-exporter-demo/keyingmaterialexporter.c @@ -155,7 +155,7 @@ session_user_set(struct session *sess, X509 *x509) if (!strncasecmp(objbuf, "CN", 2)) { - snprintf(sess->user, sizeof(sess->user) - 1, (char *)buf); + snprintf(sess->user, sizeof(sess->user) - 1, "%s", (char *)buf); } OPENSSL_free(buf);