From patchwork Wed Feb 1 04:18:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Selva Nair X-Patchwork-Id: 3034 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7300:c95:b0:82:e4b3:40a0 with SMTP id p21csp157744dyk; Tue, 31 Jan 2023 20:20:09 -0800 (PST) X-Google-Smtp-Source: AK7set9nZIabvccz/+/Luk9Ru14uQpuWLTOvRQq7tr2HCmjcMx87RE1VC+iaXwk860xsl5yS/3Fr X-Received: by 2002:a17:903:300d:b0:192:f45e:4197 with SMTP id o13-20020a170903300d00b00192f45e4197mr1255332pla.31.1675225208982; Tue, 31 Jan 2023 20:20:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675225208; cv=none; d=google.com; s=arc-20160816; b=wyFKdzHW4p41MH3AQ6gdYviwTV9cYpohdqeW1mWW/bW0U3NLb2PETVZuN1N4IarWRI 1ejTaaXKF+fSAkm5OpYx0DCC7lMJg+9g6PL+zOwkEOApfFxuHF/ttQdGMuBTjoj3cv6i yfhF2iXWRpJmJBVLiUqRN0DvEJytbMzSWU029j8jVsGCZK5QHEbYD8jhLMYBt0gaiSee B6p2jh5IQA9yuor2tTVWTI+nDYsp4n3/JR5V3zOjCSx17P7dydyNpdC4+EpFR4Omt8kA vru+YgMwfDbz1XJxv7iVM29OKKO3C79B+lerbYBZjA3eFjauoUzo+30kHEe3pRbeRonr +iNA== 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=//TVS4sORFooZ3OYDZBJnu3jNZMwt/Uj+Xk7z7HbjIs=; b=nib5B4DuENr5vVYV839e96egvykx+d5/aU1ETJ8vVAGVEA/yqb6XjLYLDpb23xRAXY F3r1dvg37eQnL/A7dEFhvdveL53S4pF9p5e41/YeFGKVwWJhChoMKZXsVribqAlrFCG1 D7Co9mP2UbU3d8RffumEhO4LkA862WDWLBuS7X+r2PV09as4zhA/R8ZsyKDfpTwe5qDT rk2OWQsidx7FpkKO6fmIO+d7kcYETd1QUgzT/eZhMLmk6YI2CoxQLSzJg1zqdOTL2/J0 fP7mwxCnPc9DXuRXan1koeadPzn7rlyLMDP7NMECyPzCsrqCysxwOfECjDxY9lceIt1k V1ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=ANMjdpEz; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=OPkj7rXE; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=c36FHBFH; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id g3-20020a170902e38300b0019609a4f16dsi16299215ple.461.2023.01.31.20.20.08 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 31 Jan 2023 20:20:08 -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=ANMjdpEz; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=OPkj7rXE; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=c36FHBFH; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1pN4ab-0005AR-D3; Wed, 01 Feb 2023 04:19:16 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pN4aY-0005AL-Rq for openvpn-devel@lists.sourceforge.net; Wed, 01 Feb 2023 04:19:14 +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:Cc:To:From:Sender:Reply-To: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=nLHC+NNj/UrtO7B2hKt88+dBiuJdlrkTIQ61Dj+vXJ8=; b=ANMjdpEzgeYObewC8IH7nba2oB +xZdoFUo2byjCEReOTAp1gfzA64VaMefdQXbbzQH0c+MWN0rw/9b81gA6JxTHM/JsuxDMYVaI/cAN Qnv8IDMQXq8yoxWbAfrCPCJuDkMlbRydg4b4HLaYPaUxDVk5M8PrOS/8lJvqZ8QPLyrc=; 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:Cc:To:From :Sender:Reply-To: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=nLHC+NNj/UrtO7B2hKt88+dBiuJdlrkTIQ61Dj+vXJ8=; b=O Pkj7rXEcM3M2g1S6uuHFsgq3GyChJyGNa8Wn7gBzvfV0ckEsYutjMw+nRdUipAc/blv434JndWvVC FhGuNX/3yZbUkjSH3rNwqTVY9A96n+GcMk2HXKiMvOeZFPKOvjxBqKGpQjSJfk4mN3MX9ghwRYEIM qrpsGc98tF2MhKcg=; Received: from mail-il1-f178.google.com ([209.85.166.178]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1pN4aT-006c04-VC for openvpn-devel@lists.sourceforge.net; Wed, 01 Feb 2023 04:19:14 +0000 Received: by mail-il1-f178.google.com with SMTP id i17so7277633ils.11 for ; Tue, 31 Jan 2023 20:19:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=nLHC+NNj/UrtO7B2hKt88+dBiuJdlrkTIQ61Dj+vXJ8=; b=c36FHBFHXHgoo7Q6odA/ve3BEshP+/GMbpao4BmWUfyHOBPgXMyl1dLN1dYBuxxttQ i2gGAOEK29ep9cs8jDqEgQj7/11Mei2tsqjWIl7xhjSx4Kh2++H6ZcnBcd/3CigqLzT/ YmyQ9zYo288Zpv5M1dt5ZmFy7ISZe3BjHLV3zyzQWYrmMtUEHnQN6F4rrSiJN/YGr8kz nN1JiiDz8H3F8J8u7yshsTAYbrS6XOVMsJWD0seOjlDBdlEW27j8/i1w31BMZ8vcSEgv Vv5tcf29JUG2lNNbxmKqK9aHgr3AbmWqZA0FL8miFSeTsF4VP96RJG15ZMuLUdc9+hXL /xaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=nLHC+NNj/UrtO7B2hKt88+dBiuJdlrkTIQ61Dj+vXJ8=; b=ZBz5qYrp32GPCB30sKmjgNdxJA+u7d9YUx75qMMCCyUNJeVjyHNBI3ZslUHWqzo1Ly JWgLjJekB99XL4Eiy+EGhbgas9VTO8rROobpf86wdackQPxMbqtM4b+PaW7SD/rY1B6c 9r5oJ7z5Xuzpr/9VEPepzLY0lCj5XhlFHXU6Qm8hJaIYWfHAz0Zon9gzaWCiAVDCoOzq RjcEoCqKw78vuq0D/z+nrCDFn8outq1b3FbqlQCwpjHoTqdb/131PkzjDMkUMK5izkI3 Ln+oBzPVRevpdCOkizox+Yv52Ry0ojW6S+p25Ymh7i+3usckOUg1fARfsAZ8aYFowHk4 Nu8w== X-Gm-Message-State: AO0yUKU8TtLUnuWogWUXYIRZzzPcsfXyI/zATfFi4E1LhbeHIEQ21mmJ COmfibLj/VZJYHRGihocTiEckxy+SZ0= X-Received: by 2002:a05:6e02:1c88:b0:311:120e:4a9e with SMTP id w8-20020a056e021c8800b00311120e4a9emr853862ill.1.1675225144061; Tue, 31 Jan 2023 20:19:04 -0800 (PST) Received: from uranus.sansel.ca (bras-vprn-tnhlon4053w-lp130-01-70-51-222-66.dsl.bell.ca. [70.51.222.66]) by smtp.gmail.com with ESMTPSA id z1-20020a029381000000b003b778515852sm131388jah.168.2023.01.31.20.19.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 20:19:03 -0800 (PST) From: selva.nair@gmail.com To: openvpn-devel@lists.sourceforge.net Date: Tue, 31 Jan 2023 23:18:31 -0500 Message-Id: <20230201041831.2259419-1-selva.nair@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Score: -0.2 (/) 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: From: Selva Nair - An item added to undo-list was not removed on error, causing attempt to free again in Undo(). Also fix a memory leak possibility in the same context. Github: fixes OpenVPN/openvpn#232 Content analysis details: (-0.2 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.166.178 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.166.178 listed in wl.mailspike.net] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [selva.nair[at]gmail.com] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from 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: 1pN4aT-006c04-VC Subject: [Openvpn-devel] [PATCH] block-dns using iservice: fix a 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?1756600948824892958?= X-GMAIL-MSGID: =?utf-8?q?1756600948824892958?= From: Selva Nair - An item added to undo-list was not removed on error, causing attempt to free again in Undo(). Also fix a memory leak possibility in the same context. Github: fixes OpenVPN/openvpn#232 Signed-off-by: Selva Nair --- src/openvpnserv/interactive.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/openvpnserv/interactive.c b/src/openvpnserv/interactive.c index 03361d66..636f32e9 100644 --- a/src/openvpnserv/interactive.c +++ b/src/openvpnserv/interactive.c @@ -780,7 +780,7 @@ static DWORD HandleBlockDNSMessage(const block_dns_message_t *msg, undo_lists_t *lists) { DWORD err = 0; - block_dns_data_t *interface_data; + block_dns_data_t *interface_data = NULL; HANDLE engine = NULL; LPCWSTR exe_path; @@ -794,6 +794,7 @@ HandleBlockDNSMessage(const block_dns_message_t *msg, undo_lists_t *lists) interface_data = malloc(sizeof(block_dns_data_t)); if (!interface_data) { + delete_block_dns_filters(engine); return ERROR_OUTOFMEMORY; } interface_data->engine = engine; @@ -818,8 +819,17 @@ HandleBlockDNSMessage(const block_dns_message_t *msg, undo_lists_t *lists) BLOCK_DNS_IFACE_METRIC); if (!err) { - set_interface_metric(msg->iface.index, AF_INET6, - BLOCK_DNS_IFACE_METRIC); + err = set_interface_metric(msg->iface.index, AF_INET6, + BLOCK_DNS_IFACE_METRIC); + } + if (err) + { + /* try to restore the interface metric values in case changed */ + set_interface_metric(msg->iface.index, AF_INET, + interface_data->metric_v4); + set_interface_metric(msg->iface.index, AF_INET, + interface_data->metric_v4); + RemoveListItem(&(*lists)[block_dns], CmpAny, NULL); } } } @@ -853,6 +863,7 @@ HandleBlockDNSMessage(const block_dns_message_t *msg, undo_lists_t *lists) if (err && engine) { delete_block_dns_filters(engine); + free(interface_data); } return err;