From patchwork Mon Oct 8 05:35:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lev Stipakov X-Patchwork-Id: 512 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director10.mail.ord1d.rsapps.net ([172.27.255.59]) by backend30.mail.ord1d.rsapps.net with LMTP id OCBfG2+Iu1tCbAAAIUCqbw for ; Mon, 08 Oct 2018 12:40:15 -0400 Received: from proxy20.mail.iad3a.rsapps.net ([172.27.255.59]) by director10.mail.ord1d.rsapps.net with LMTP id sHWeGG+Iu1u0UwAApN4f7A ; Mon, 08 Oct 2018 12:40:15 -0400 Received: from smtp5.gate.iad3a ([172.27.255.59]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy20.mail.iad3a.rsapps.net with LMTP id uPzOEm+Iu1s7NwAAtfLT2w ; Mon, 08 Oct 2018 12:40:15 -0400 X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO X-Virus-Scanned: OK X-Orig-To: openvpnslackdevel@openvpn.net X-Originating-Ip: [216.105.38.7] Authentication-Results: smtp5.gate.iad3a.rsapps.net; iprev=pass policy.iprev="216.105.38.7"; spf=pass smtp.mailfrom="openvpn-devel-bounces@lists.sourceforge.net" smtp.helo="lists.sourceforge.net"; dkim=fail (signature verification failed) header.d=sourceforge.net; dkim=fail (signature verification failed) header.d=sf.net; dkim=fail (signature verification failed) header.d=gmail.com; dmarc=fail (p=none; dis=none) header.from=gmail.com X-Suspicious-Flag: YES X-Classification-ID: d4a175dc-cb18-11e8-bdde-525400de824c-1-1 Received: from [216.105.38.7] ([216.105.38.7:65317] helo=lists.sourceforge.net) by smtp5.gate.iad3a.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 33/69-24818-E688BBB5; Mon, 08 Oct 2018 12:40:14 -0400 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.90_1) (envelope-from ) id 1g9YYt-0006Vq-NH; Mon, 08 Oct 2018 16:39:15 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1g9YYr-0006Vk-8A for openvpn-devel@lists.sourceforge.net; Mon, 08 Oct 2018 16:39:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc: MIME-Version:Content-Type:Content-Transfer-Encoding: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=LzcxjqxMbg5yvGDBf25x11HIQS/OSUAFQvMl+Nb3S0w=; b=aAFzoVxWV3ripVpGW9wXh6P1LO hAWvYa/fs6EXmkP9mYSw3v8yhcUAeym2UJZj2p516/0CR+XwK1ePiy5VDHbbCESl3+u1SMZqzsBsR Nyj1HsaHTYVzJmY07jmxN3R48HcGnA8QdK2c3JtIk2OX2judUeDgjMfw/7KeIKylIhVQ=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc:MIME-Version: Content-Type:Content-Transfer-Encoding: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=LzcxjqxMbg5yvGDBf25x11HIQS/OSUAFQvMl+Nb3S0w=; b=Az0R/TvojNJH03TUMVQKPq/Obe H/4l+ZjmvNdaC4MhDGzhK5pn3/Y3ZP58JHsSJ+UjBVMO6RDQe2QWrd1pTZaqdZEFh5zHICAbhP54w zXBedCANN8Y2XHbi/o4C3tifJK/p52CbxxfHd8lARyka56dzflRwBProJcfMi+nvrCP0=; Received: from mail-ed1-f66.google.com ([209.85.208.66]) by sfi-mx-4.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.90_1) id 1g9YYm-00EYtr-DS for openvpn-devel@lists.sourceforge.net; Mon, 08 Oct 2018 16:39:12 +0000 Received: by mail-ed1-f66.google.com with SMTP id h13-v6so6720592edq.0 for ; Mon, 08 Oct 2018 09:39:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=LzcxjqxMbg5yvGDBf25x11HIQS/OSUAFQvMl+Nb3S0w=; b=sbHF30U69oGN7UBXgNRUBrEGm0rapYsBMkP4NPtGIUyGjEiqHILakIJXx6mk84kNeY 1jY5g0QlFOJpxUZjaUQ5NeRL6rX9OL13keC8eerFduRxEN74ZwVihVoNfp03jXVFT5Pn 6K5wNOMsk3uWhCWWfjFEdE9CSA3ixCzPriTFlRAJS6IlXSTr2OtcHJ575yqBzh1l7kuj ps7IuAqTDtmcz60+OXi1HGLqjQ5/1T3awA3+Gbg7QNG/dVsBX5vXs35e2UwDGDn0ZQZ9 AsRGhgESv97ZdcmPuZ0ykhGndXXiay6V5NjjGOuCUyVtDHY+YPlZ0KEvPzo1hNFj3PC8 2WPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=LzcxjqxMbg5yvGDBf25x11HIQS/OSUAFQvMl+Nb3S0w=; b=NKZAc9T+oia9WzNWaDe7dMtUfHvo+F/P9TUQCfDUPKB7hTy8NQStQS9uuX5OOlsWuO 9FLP/JtMQzyZhX0gMyYLtKrqW9ngu8PKm6iebHSRfcjhDRpFbJhNuPhAX0M21dWgfQ38 elygWaLhQr3Q5IprbCtGKydf6GZEo5nabBesgeSVqGzJO157naXvRN+eeuotg6y1/ayz rXCheJtcbfmF7E3IYINya5vykeEwXmwFFBiO8FjjbK/m3eEXM/3i0Ug+zNrvvE1U0dZz n7FKtFEBB041KxyjvvERIeK36a6M47ov6nI7ekVvaJjECy3oRY7bNafPbBafKtOkBiws Q6+g== X-Gm-Message-State: ABuFfohXWfpOuypE43mgoR4SBFyAJDjN7zOvLNAUwRrPnEyP/ebGGctW 9OvRfy8C9+hLJRk8J1y7g/3ohURv+f4= X-Google-Smtp-Source: ACcGV63uBSN3oTfW3TQcPBhKYF39dPQMSIICjBMSm9UiSfvKHaDkUAEDiAOgBMzdMea+TkPc1BwRug== X-Received: by 2002:a50:89ab:: with SMTP id g40-v6mr29261699edg.257.1539016741337; Mon, 08 Oct 2018 09:39:01 -0700 (PDT) Received: from stipakov.fi (stipakov.fi. [128.199.52.117]) by smtp.gmail.com with ESMTPSA id c40-v6sm5370764edb.41.2018.10.08.09.38.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 08 Oct 2018 09:39:00 -0700 (PDT) From: Lev Stipakov To: openvpn-devel@lists.sourceforge.net Date: Mon, 8 Oct 2018 19:35:54 +0300 Message-Id: <1539016554-23503-1-git-send-email-lstipakov@gmail.com> X-Mailer: git-send-email 2.7.4 X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [209.85.208.66 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (lstipakov[at]gmail.com) -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.208.66 listed in wl.mailspike.net] -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 -0.0 AWL AWL: Adjusted score from AWL reputation of From: address X-Headers-End: 1g9YYm-00EYtr-DS Subject: [Openvpn-devel] [PATCH] interactive.c: fix usage of potentially uninitialized variable 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: , MIME-Version: 1.0 Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox From: Lev Stipakov In function netsh_dns_cmd() it is possible to jump on a label and call free() on uninitialized pointer. Move pointer initialization above jump and add NULL check before free() call. To fix a few warnings which are treated as errors with SDL enabled, initialize few pointers with a NULL. Signed-off-by: Lev Stipakov --- src/openvpnserv/interactive.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/openvpnserv/interactive.c b/src/openvpnserv/interactive.c index 8f92c24..369980b 100644 --- a/src/openvpnserv/interactive.c +++ b/src/openvpnserv/interactive.c @@ -1015,6 +1015,7 @@ netsh_dns_cmd(const wchar_t *action, const wchar_t *proto, const wchar_t *if_nam DWORD err = 0; int timeout = 30000; /* in msec */ wchar_t argv0[MAX_PATH]; + wchar_t *cmdline = NULL; if (!addr) { @@ -1039,7 +1040,7 @@ netsh_dns_cmd(const wchar_t *action, const wchar_t *proto, const wchar_t *if_nam /* max cmdline length in wchars -- include room for worst case and some */ size_t ncmdline = wcslen(fmt) + wcslen(if_name) + wcslen(addr) + 32 + 1; - wchar_t *cmdline = malloc(ncmdline*sizeof(wchar_t)); + cmdline = malloc(ncmdline*sizeof(wchar_t)); if (!cmdline) { err = ERROR_OUTOFMEMORY; @@ -1055,7 +1056,10 @@ netsh_dns_cmd(const wchar_t *action, const wchar_t *proto, const wchar_t *if_nam err = ExecCommand(argv0, cmdline, timeout); out: - free(cmdline); + if (cmdline) + { + free(cmdline); + } return err; } @@ -1350,7 +1354,7 @@ RunOpenvpn(LPVOID p) { HANDLE pipe = p; HANDLE ovpn_pipe, svc_pipe; - PTOKEN_USER svc_user, ovpn_user; + PTOKEN_USER svc_user = NULL, ovpn_user = NULL; HANDLE svc_token = NULL, imp_token = NULL, pri_token = NULL; HANDLE stdin_read = NULL, stdin_write = NULL; HANDLE stdout_write = NULL;