From patchwork Sun Mar 21 03:46:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kristof Provost via Openvpn-devel X-Patchwork-Id: 1642 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director13.mail.ord1d.rsapps.net ([172.30.191.6]) by backend30.mail.ord1d.rsapps.net with LMTP id GCarDIlgV2CxDwAAIUCqbw (envelope-from ) for ; Sun, 21 Mar 2021 11:04:41 -0400 Received: from proxy19.mail.ord1d.rsapps.net ([172.30.191.6]) by director13.mail.ord1d.rsapps.net with LMTP id mCt2DIlgV2CYWwAA91zNiA (envelope-from ) for ; Sun, 21 Mar 2021 11:04:41 -0400 Received: from smtp3.gate.ord1c ([172.30.191.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy19.mail.ord1d.rsapps.net with LMTPS id wLEnDIlgV2BQeAAAyH2SIw (envelope-from ) for ; Sun, 21 Mar 2021 11:04:41 -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: smtp3.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=pass header.d=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=rozman.si; dmarc=pass (p=none; dis=none) header.from=lists.sourceforge.net X-Suspicious-Flag: NO X-Classification-ID: c2a3f2e2-8a56-11eb-8a4a-842b2b47481a-1-1 Received: from [216.105.38.7] ([216.105.38.7:34438] helo=lists.sourceforge.net) by smtp3.gate.ord1c.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id AF/BE-14603-88067506; Sun, 21 Mar 2021 11:04:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type: Reply-To:From:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Subject:MIME-Version:References:In-Reply-To: Message-Id:Date:To:Sender:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=emLz0Ri+AiT7d+6U6fb4uF1u9InbkiKoxbcoyqWV4Ts=; b=UpoiQr6QBHuABtmc3UgzyY8a1 JSwJkCGOCmA9bzPPo0cUzS2DkKsw4H4Qkm3qPzUrPDxO0htypG5W5+yL6VHZHwvatPZ8X1D5n8Ly+ c5/CphLnsiSHM87jaOf60oAgx2HQ5DkqXQizQPlY7n8YBKVN1ebUKoY5EQOR+jjVOYYoY=; 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.92.3) (envelope-from ) id 1lNzcQ-000147-0R; Sun, 21 Mar 2021 15:03:54 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.3) (envelope-from ) id 1lNzcO-000140-TL for openvpn-devel@lists.sourceforge.net; Sun, 21 Mar 2021 15:03:52 +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: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:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=FfNJnfDy+UfR0Vu4Wrgl1m2WoMrO+wt4HasQITtbID4=; b=DyWmk4i5radFIstoYtEhoB4v/l TuJFFjtyTAdm2+dt0EpGNk9ZXVgxRkvwfHwoMUXu8NE7PTJ81H16vR9vXBFVo0I2hYFwftLVm5ZwS NhYcIQFvgYACJYZcOazVlyDRiN/zMtyAE3YZxFnml6lO1GIo9yTwob5Dk3TRZ2qO2r/U=; 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: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:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=FfNJnfDy+UfR0Vu4Wrgl1m2WoMrO+wt4HasQITtbID4=; b=Q31Sc1uMZtvIvOSF6hzIMt/H/k 8OLU88gsuyGG+9u7yYBgwm0wTwpvCYI23BBBNtWi1HBTWSM+j4PSfJj2EtTBqDrOLmVSqr692JGf9 FQhrlfJcpdt3MXyptv4mH1myu+e6oDi0tRSnxn254V9WnJfn96U4aX8eOXY5S+XUpG/8=; Received: from krn.amebis.si ([93.103.235.207]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.3) id 1lNzcG-0007cE-Ly for openvpn-devel@lists.sourceforge.net; Sun, 21 Mar 2021 15:03:52 +0000 Received: by krn.amebis.si (Postfix, from userid 982) id 9054918E8787; Sun, 21 Mar 2021 15:46:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rozman.si; s=default; t=1616338005; bh=FfNJnfDy+UfR0Vu4Wrgl1m2WoMrO+wt4HasQITtbID4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YCWezT22UvjgjV7r//Whzkb1IXSl0RYWHIcRJldDc0B5awwHS06lbS976bufJruRm c6f38y8iHNoECG57C6Rid5dZqSK/2ebe0rsf18cbO9PY0R96cLWuzKv8fedfAxnPB9 Y7n0MoplAXqpIj9zXZsJYsp5CnsFbtuF3fHWaGRM= X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on krn.amebis.doma X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.4 Received: from SR6.amebis.doma (unknown [IPv6:2a01:260:4101:1464:8095:bdbd:413f:700f]) by krn.amebis.si (Postfix) with ESMTP id EC23F18E878B; Sun, 21 Mar 2021 15:46:42 +0100 (CET) To: openvpn-devel@lists.sourceforge.net Date: Sun, 21 Mar 2021 15:46:26 +0100 Message-Id: <20210321144627.1621-4-simon@rozman.si> X-Mailer: git-send-email 2.30.0.windows.2 In-Reply-To: <20210321144627.1621-1-simon@rozman.si> References: <20210321144627.1621-1-simon@rozman.si> MIME-Version: 1.0 X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 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: rozman.si] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an 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 X-Headers-End: 1lNzcG-0007cE-Ly Subject: [Openvpn-devel] [PATCH 4/5] tapctl: Resolve MSVC C4996 warnings 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: , X-Patchwork-Original-From: Simon Rozman via Openvpn-devel From: Kristof Provost via Openvpn-devel Reply-To: Simon Rozman Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox wcsncat() was declared unsafe in favour of wcsncat_s(). However, the string concatenation follows the string length check, making wcsncat() safe too. Code analysis is just not smart enough (yet) to detect this. The code was refactored to use wcscat_s() MSVC is considering as "safe". Signed-off-by: Simon Rozman --- src/tapctl/tap.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/tapctl/tap.c b/src/tapctl/tap.c index dd4a10a3..3f76c43a 100644 --- a/src/tapctl/tap.c +++ b/src/tapctl/tap.c @@ -2,7 +2,7 @@ * tapctl -- Utility to manipulate TUN/TAP adapters on Windows * https://community.openvpn.net/openvpn/wiki/Tapctl * - * Copyright (C) 2018-2020 Simon Rozman + * Copyright (C) 2018-2021 Simon Rozman * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 @@ -73,14 +73,13 @@ find_function(const WCHAR *libname, const char *funcname, HMODULE *m) return NULL; } - size_t len = _countof(libpath) - wcslen(libpath) - 1; - if (len < wcslen(libname) + 1) + if (wcslen(libpath) + 1 /*\*/ + wcslen(libname) >= _countof(libpath)) { SetLastError(ERROR_INSUFFICIENT_BUFFER); return NULL; } - wcsncat(libpath, L"\\", len); - wcsncat(libpath, libname, len-1); + wcscat_s(libpath, _countof(libpath), L"\\"); + wcscat_s(libpath, _countof(libpath), libname); *m = LoadLibraryW(libpath); if (*m == NULL)