| Message ID | 20210322074359.527-1-simon@rozman.si |
|---|---|
| State | Accepted |
| Headers |
Return-Path: <openvpn-devel-bounces@lists.sourceforge.net> Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director12.mail.ord1d.rsapps.net ([172.31.255.6]) by backend30.mail.ord1d.rsapps.net with LMTP id GPZ2FghLWGALOwAAIUCqbw (envelope-from <openvpn-devel-bounces@lists.sourceforge.net>) for <patchwork@openvpn.net>; Mon, 22 Mar 2021 03:45:12 -0400 Received: from proxy6.mail.iad3b.rsapps.net ([172.31.255.6]) by director12.mail.ord1d.rsapps.net with LMTP id eKZXFghLWGDHXgAAIasKDg (envelope-from <openvpn-devel-bounces@lists.sourceforge.net>) for <patchwork@openvpn.net>; Mon, 22 Mar 2021 03:45:12 -0400 Received: from smtp12.gate.iad3b ([172.31.255.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy6.mail.iad3b.rsapps.net with LMTPS id qB3PEAhLWGAGfwAARawThA (envelope-from <openvpn-devel-bounces@lists.sourceforge.net>) for <patchwork@openvpn.net>; Mon, 22 Mar 2021 03:45:12 -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: smtp12.gate.iad3b.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: 87d44324-8ae2-11eb-9da3-525400ae1f9d-1-1 Received: from [216.105.38.7] ([216.105.38.7:55378] helo=lists.sourceforge.net) by smtp12.gate.iad3b.rsapps.net (envelope-from <openvpn-devel-bounces@lists.sourceforge.net>) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 20/3E-29454-70B48506; Mon, 22 Mar 2021 03:45:11 -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=vldVF3kzEjHE/0LZDbWiq1+TEy1KgRwo/mhT95OTjY0=; b=Te/Cyd508OJSuIVJu4gthuUmG EOG9u0yIYPBoizAz9SeZj47Fjdn41HCVRA2QqW7aOPSIU4xxthJtEvpJ7KCnT87JhDOaHW5+8IZ6o ssqoQqgP8m06swudxVv+SD5zy0AXrmy1K7DKUgKZp1b4g0SrIqI6LPj/Mj8UJLVMWlIGU=; 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 <openvpn-devel-bounces@lists.sourceforge.net>) id 1lOFEX-0001mv-TG; Mon, 22 Mar 2021 07:44:17 +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 <simon@rozman.si>) id 1lOFEU-0001mN-Jd for openvpn-devel@lists.sourceforge.net; Mon, 22 Mar 2021 07:44: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: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=dccns4SAF8vInudrq/1jVPWumBFRVdSGQIq5YOXavfU=; b=mmJ58lAqQFFXTXVE3/Ts9dJKNx 3El5X9yqJdFG5MLkz2exDxP60pSt+Hk9Hh4nBSFFH014Xx/auhspveU20D+T23PIFVbG3pkp/3qRy 5qsBZ72C5m+PUJs63+pml3xg7KXbayfrGdfEPffJf9oFO9sF7qk3rjO0Wtf25EZ2b0gc=; 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=dccns4SAF8vInudrq/1jVPWumBFRVdSGQIq5YOXavfU=; b=Fk6Ds2rrmHHH77pmTLT4bBj/zW GL0N3KREkYj7NL92RmoQFvhVaz9tsgd1EQ3+21jCXubyTmEj/HDb5Qb6NIzHNvnd8eJaq0GDwrzt5 Bx4/ASvuC+AGXEKysMv4T2mKqLSYiPYZe4a0Ba+XQQ0MZjLToa43QfXeNAk0FVetHApI=; 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 1lOFEP-0001Yz-L1 for openvpn-devel@lists.sourceforge.net; Mon, 22 Mar 2021 07:44:14 +0000 Received: by krn.amebis.si (Postfix, from userid 982) id 4E77B18E878A; Mon, 22 Mar 2021 08:44:03 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rozman.si; s=default; t=1616399043; bh=dccns4SAF8vInudrq/1jVPWumBFRVdSGQIq5YOXavfU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sIPIjXubz6smYeEr/doW7qB66tIYaRyiR1eghosxDhj4wyW1OmVhjp64zudTHorF0 Fh+U2hdE+xkSKXO3R+gmoOJLBR2GC3R6HKioDd+c3mO7UGGUnWIUsfugeU4BVLQ9iw qp0YY3jl24TmsYCkmV6mbnE06R1ImG+Fy4/gT1Do= 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 autolearn=unavailable autolearn_force=no version=3.4.4 Received: from SR6.amebis.doma (unknown [IPv6:2a01:260:4101:1464:a506:9854:23ad:d966]) by krn.amebis.si (Postfix) with ESMTP id 2FED418E8787; Mon, 22 Mar 2021 08:44:00 +0100 (CET) To: openvpn-devel@lists.sourceforge.net Date: Mon, 22 Mar 2021 08:43:59 +0100 Message-Id: <20210322074359.527-1-simon@rozman.si> X-Mailer: git-send-email 2.30.0.windows.2 In-Reply-To: <a002b6f5-3201-cb8c-c05c-26d919dd8696@rfc2549.org> References: <a002b6f5-3201-cb8c-c05c-26d919dd8696@rfc2549.org> MIME-Version: 1.0 X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -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: 1lOFEP-0001Yz-L1 Subject: [Openvpn-devel] [PATCH v2 4/5] tapctl: Resolve MSVC C4996 warnings X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: <openvpn-devel.lists.sourceforge.net> List-Unsubscribe: <https://lists.sourceforge.net/lists/options/openvpn-devel>, <mailto:openvpn-devel-request@lists.sourceforge.net?subject=unsubscribe> List-Archive: <http://sourceforge.net/mailarchive/forum.php?forum_name=openvpn-devel> List-Post: <mailto:openvpn-devel@lists.sourceforge.net> List-Help: <mailto:openvpn-devel-request@lists.sourceforge.net?subject=help> List-Subscribe: <https://lists.sourceforge.net/lists/listinfo/openvpn-devel>, <mailto:openvpn-devel-request@lists.sourceforge.net?subject=subscribe> From: Simon Rozman via Openvpn-devel <openvpn-devel@lists.sourceforge.net> Reply-To: Simon Rozman <simon@rozman.si> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox |
| Series |
None
|
|
Commit Message
haixiao.yan.cn--- via Openvpn-devel
March 21, 2021, 8:43 p.m. UTC
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 <simon@rozman.si>
---
src/tapctl/tap.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
Comments
Acked-by: Gert Doering <gert@greenie.muc.de> It's the same code change as in v1, just the comment rewritten as Arne asked for (I found the other one okay-ish, but this is more in line with our other code, and indeed "less thinking required on read") and a new helper variable for the total length. Code looks good, test build on Ubuntu 18/MingW also had no complaints. Your patch has been applied to the master branch. commit ef5b922aedead7159718ddbf40fc9f5be1b2b203 Author: Simon Rozman via Openvpn-devel Date: Mon Mar 22 08:43:59 2021 +0100 tapctl: Resolve MSVC C4996 warnings Signed-off-by: Simon Rozman <simon@rozman.si> Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <20210322074359.527-1-simon@rozman.si> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21774.html Signed-off-by: Gert Doering <gert@greenie.muc.de> -- kind regards, Gert Doering
Hi, On Mon, Mar 22, 2021 at 10:10:42AM +0100, Gert Doering wrote: > Acked-by: Gert Doering <gert@greenie.muc.de> > > It's the same code change as in v1, just the comment rewritten as Arne > asked for (I found the other one okay-ish, but this is more in line with > our other code, and indeed "less thinking required on read") and a new > helper variable for the total length. > > Code looks good, test build on Ubuntu 18/MingW also had no complaints. > > Your patch has been applied to the master branch. > > commit ef5b922aedead7159718ddbf40fc9f5be1b2b203 > Author: Simon Rozman via Openvpn-devel > Date: Mon Mar 22 08:43:59 2021 +0100 My local tree was in a slightly funny state (the tip commit had a new ID due to an accidential "git commit --amend" on the wrong head), so I had to rebase and this commit got a new ID commit e5e9a07e8baee4065b7dfd65736bfa77b8329cfc (HEAD -> master, stable/master, mattock/master, gitlab/master, github/master) Author: Simon Rozman via Openvpn-devel <openvpn-devel@lists.sourceforge.net> Date: Mon Mar 22 08:43:59 2021 +0100 tapctl: Resolve MSVC C4996 warnings (and I forgot to change the From: line again, sorry, again) Must be Monday :-( gert
Hi, On Mon, Mar 22, 2021 at 10:17:17AM +0100, Gert Doering wrote: > My local tree was in a slightly funny state (the tip commit had a new > ID due to an accidential "git commit --amend" on the wrong head), so > I had to rebase and this commit got a new ID > > commit e5e9a07e8baee4065b7dfd65736bfa77b8329cfc (HEAD -> master, stable/master, mattock/master, gitlab/master, github/master) > Author: Simon Rozman via Openvpn-devel <openvpn-devel@lists.sourceforge.net> > Date: Mon Mar 22 08:43:59 2021 +0100 > > tapctl: Resolve MSVC C4996 warnings > > (and I forgot to change the From: line again, sorry, again) By popular demand (Lev) this was now cherry-picked to 2.5 as well. commit 64547d552dbcadd826a30a4ba122d590d87504f6 (HEAD -> release/2.5) Author: Simon Rozman <simon@rozman.si> Date: Mon Mar 22 08:43:59 2021 +0100 tapctl: Resolve MSVC C4996 warnings gert
diff --git a/src/tapctl/tap.c b/src/tapctl/tap.c index dd4a10a3..563c07f6 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 <simon@rozman.si> + * Copyright (C) 2018-2021 Simon Rozman <simon@rozman.si> * * 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,15 @@ 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) + /* +1 for the path seperator '\' */ + const size_t path_length = wcslen(libpath) + 1 + wcslen(libname); + if (path_length >= _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)