From patchwork Mon Oct 8 07:12:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lev Stipakov X-Patchwork-Id: 516 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director11.mail.ord1d.rsapps.net ([172.30.191.6]) by backend30.mail.ord1d.rsapps.net with LMTP id kD4UHfWeu1sMTwAAIUCqbw for ; Mon, 08 Oct 2018 14:16:21 -0400 Received: from proxy14.mail.ord1d.rsapps.net ([172.30.191.6]) by director11.mail.ord1d.rsapps.net with LMTP id eBKfHPWeu1vZWAAAvGGmqA ; Mon, 08 Oct 2018 14:16:21 -0400 Received: from smtp2.gate.ord1c ([172.30.191.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy14.mail.ord1d.rsapps.net with LMTP id MN9qHPWeu1vlNQAAtEH5vw ; Mon, 08 Oct 2018 14:16:21 -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: smtp2.gate.ord1c.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: 41ba3750-cb26-11e8-ae2c-842b2b4e7063-1-1 Received: from [216.105.38.7] ([216.105.38.7:29356] helo=lists.sourceforge.net) by smtp2.gate.ord1c.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id E3/F6-32381-5FE9BBB5; Mon, 08 Oct 2018 14:16:21 -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 1g9a41-0000Bz-CB; Mon, 08 Oct 2018 18:15:29 +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 1g9a3z-0000Bp-VH for openvpn-devel@lists.sourceforge.net; Mon, 08 Oct 2018 18:15:27 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=References:In-Reply-To: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:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=Ph1dZ6Non+5RdpNh22gFwrey0AHKQHOmZC45KckZ12U=; b=bbySAPKTxuveDacWv7We0bOofc ALVdDYbO0o7T+bEOvd4Ox2EI4A/zT8U1xTE7RnWDRV3+FmM14ggR6V2B60nkOHdXudXkMWQl6ZQ82 DWfsuFE0BD/FA1CsdFSL6gqka6fZct6XUhQtCb8W2PWzkkbeux0dWwbFiheVdbXyUIZI=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=References:In-Reply-To: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:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=Ph1dZ6Non+5RdpNh22gFwrey0AHKQHOmZC45KckZ12U=; b=M5YWbWzjuXrQhwpv3MtSl4/OUF R0S2N5bzYVhVqCGSe06awFhTgZzu5nZGfFQivagiNyaSfX1PaPo78Y6/QNL8wySOInOd7+zRSRvmF 8THjp4lW6RY06jQNfNxLw58sEx+Oj47B91Zjhk2OYerKOny+F0AYxZ39gVw+I44mMBC0=; Received: from mail-ed1-f44.google.com ([209.85.208.44]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.90_1) id 1g9a3y-003OHj-HJ for openvpn-devel@lists.sourceforge.net; Mon, 08 Oct 2018 18:15:27 +0000 Received: by mail-ed1-f44.google.com with SMTP id r1-v6so3933093edd.7 for ; Mon, 08 Oct 2018 11:15:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=Ph1dZ6Non+5RdpNh22gFwrey0AHKQHOmZC45KckZ12U=; b=d4HAiGkBdXJTvWlkzIsSnBRKd3Yg1Hf7EbMeZhQ80mLf1x+fOLfq5liQ8DGl7jQSlx fKSRrUc95BDWAY/2IIGmii8iJsQRRhpJTRlDwVwmu5pgBOhj1E9Zp8aqb7lpZfEjXnMD 6BWrAjmvlbYcun0ntQ872PL8/uTFPfcTJx0duc0iCpb11JY8LSTRg3Pvx/XxuxkahL4a 3pbldbcVnTkAsPLTZ5gKOMRhZunQ+IMZAqcsy51YkY1ENho6RLRLp9fNRuTfYBnm1cP7 bdloyJODF4j4hmRpQb6IljiCyVTBVGvZ9HdO+G9NtcmnZZUjhbMyx446SFF5C1d0l4Sa s5uA== 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:in-reply-to :references; bh=Ph1dZ6Non+5RdpNh22gFwrey0AHKQHOmZC45KckZ12U=; b=lzNR+1IN3uXosECJ1EN/yfh2WuMBysh+nJbofvNh8buvwNxpbdngx4UAYQNTGY5J/Y DSZkJ+J+jtw2WZHVFckMf/3f8NQXsYvlSeMBr/5t+/Wa+3CmzRyD9vLACn1y0FHEP28H E5fciI3q/Ec78uYkuG8KRNlLLHxu6bCCcPBBlSOh85mgbenm1ObylsWOFdLA2jRhwpD+ e3qk1c5nWfwu9qmO0yHeXhXHGi8Y17lt3wQVNW8WA9nBtoq6lIsBBYanDomUr5SV8r// XeIL9++dwZl8bW041ucdkWSgl3j/JGQiKcX5nlm2LFn44GrmbisqekI4DlbZbUkR10N6 gerg== X-Gm-Message-State: ABuFfohxlFq8W1oYdEmJQ6q9f1JVcStec4F0hGWkZbg+1aBxdlqpy4Lr 9d/xd1EhWY87pbg0D5rt4/RyxH/z2NU= X-Google-Smtp-Source: ACcGV61SAYs96fSlUuL6oSykj7wcpm1TdZQb/sJcx5RYfWSMUDVH1PAs4ovVZbzSflZaOVcs+YkL0w== X-Received: by 2002:a50:bc12:: with SMTP id j18-v6mr9094069edh.154.1539022519590; Mon, 08 Oct 2018 11:15:19 -0700 (PDT) Received: from stipakov.fi (stipakov.fi. [128.199.52.117]) by smtp.gmail.com with ESMTPSA id c27-v6sm5568721edc.4.2018.10.08.11.15.18 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 08 Oct 2018 11:15:19 -0700 (PDT) From: Lev Stipakov To: openvpn-devel@lists.sourceforge.net Date: Mon, 8 Oct 2018 21:12:58 +0300 Message-Id: <1539022378-24485-1-git-send-email-lstipakov@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <20181008175242.GS962@greenie.muc.de> References: <20181008175242.GS962@greenie.muc.de> X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 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.44 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [209.85.208.44 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -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: 1g9a3y-003OHj-HJ Subject: [Openvpn-devel] [PATCH v2] 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. To fix a few warnings which are treated as errors with SDL enabled, initialize pointers with NULL. Signed-off-by: Lev Stipakov Acked-by: selva.nair@gmail.com Signed-off-by: Lev Stipakov <lev@openvpn.net>
--- v2: - remove NULL check before free() call - remove unneeded NULL initializations in function body src/openvpnserv/interactive.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/openvpnserv/interactive.c b/src/openvpnserv/interactive.c index 8f92c24..4a571f5 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; @@ -1350,7 +1351,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; @@ -1403,7 +1404,6 @@ RunOpenvpn(LPVOID p) goto out; } len = 0; - svc_user = NULL; while (!GetTokenInformation(svc_token, TokenUser, svc_user, len, &len)) { if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) @@ -1436,7 +1436,6 @@ RunOpenvpn(LPVOID p) goto out; } len = 0; - ovpn_user = NULL; while (!GetTokenInformation(imp_token, TokenUser, ovpn_user, len, &len)) { if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)