| Message ID | 20230329090447.246561-1-frank@lichtenheld.com |
|---|---|
| State | Superseded |
| Headers | show
Return-Path: <openvpn-devel-bounces@lists.sourceforge.net>
Delivered-To: patchwork@openvpn.net
Received: by 2002:a05:7301:5492:b0:b2:b40d:92f9 with SMTP id ab18csp303395dyc;
Wed, 29 Mar 2023 02:05:42 -0700 (PDT)
X-Google-Smtp-Source:
AK7set9ng/H8lvrlECvTnT1glSptEFGfeJ0c9JJPq/CAXwayFsu3CZIHk1NyVkjgPcH7XllR6TRH
X-Received: by 2002:a05:6a20:7a85:b0:cb:7958:7071 with SMTP id
u5-20020a056a207a8500b000cb79587071mr15653316pzh.19.1680080741811;
Wed, 29 Mar 2023 02:05:41 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1680080741; cv=none;
d=google.com; s=arc-20160816;
b=jet8Vlw32QeK7njvtTH8y0+lUrkCFBp0DeGcjY2a3rbHEwhoX+rTKHS9q05Orhguz2
vriYPi63QPPBLQu6qR3mioKYPC29V9pe/qocrgnoB65MR0DGfYReF3oQVADQYI6Ced0n
uOgj7wxPibPu8t3IQsBiL+8nxQgpG/JiGV8IJUY1Kiiw0Y574nXgl2RLaa5VrYO/j9Uk
IWctdtQnS4eCh0GEMLO4idxcljNfPXL9l4RQ/IGbWzvBb4ReVUC+aMjYLp+3CoNcmPY+
YdJ+K5gQSBGDBV5f9+Pp7NXqfCInvjfa6W15TT1Sql2Ash0kF90jDByw+qzZAy1LPqKA
tRtw==
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:references:in-reply-to:message-id:date:to:from
:dkim-signature:dkim-signature:dkim-signature;
bh=vPVm1ksZ3eK9kmQbhSwaktBUpAjYoWbJLTePhU45mqc=;
b=rLU7Q71HxHYGTauYH3z7/QAH/a3iL8xkZrJNI2iJxTLxCYKLeW4tZaLyp7vWmnZeu5
B+gQyo92DxHOrkOsTnoQ8OaB/KnLMqpT9W0YcqwetO4kfvfxRTTwQAoOxJ/cNiMHw0vp
7VRydrE3JAQ4B2V/nwzHDmSZ7gIxKNlMkHvlLVwD0oltgtaT1Z742ZLwlNqQ2/HbMQuF
TMJ8djfj2arUjUR1mDoZVKP8P5SF/sz/LQFsI7OZqQQp6Nrqzph0Txn/NbiGxl934GIi
Oasdf78aXJZs+3f7sqc1FvOh2QL6Jabld8MOAtkDfolqwqIfAa5oTfNiN2SCf6I3advD
NHXg==
ARC-Authentication-Results: i=1; mx.google.com;
dkim=neutral (body hash did not verify) header.i=@sourceforge.net
header.s=x header.b=U51OXjCd;
dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x
header.b=BDbQDbP0;
dkim=neutral (body hash did not verify) header.i=@lichtenheld.com
header.s=MBO0001 header.b=JZ9Z18Pr;
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
Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7])
by mx.google.com with ESMTPS id
s129-20020a632c87000000b00502e4c357casi32467220pgs.772.2023.03.29.02.05.41
(version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128);
Wed, 29 Mar 2023 02:05:41 -0700 (PDT)
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=U51OXjCd;
dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x
header.b=BDbQDbP0;
dkim=neutral (body hash did not verify) header.i=@lichtenheld.com
header.s=MBO0001 header.b=JZ9Z18Pr;
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
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.95)
(envelope-from <openvpn-devel-bounces@lists.sourceforge.net>)
id 1phRkD-00084B-O8;
Wed, 29 Mar 2023 09:05:24 +0000
Received: from [172.30.20.202] (helo=mx.sourceforge.net)
by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls
TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95)
(envelope-from <frank@lichtenheld.com>) id 1phRjt-00080h-Tw
for openvpn-devel@lists.sourceforge.net;
Wed, 29 Mar 2023 09:05:05 +0000
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
d=sourceforge.net; s=x; h=Content-Transfer-Encoding:Content-Type:MIME-Version
:References:In-Reply-To:Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc:
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=LNnoBH/aVyGJ7WRg7LTaFXPb9tT6X+xdvFAcepflLG8=; b=U51OXjCdLwGOT756SRnZqd46re
QBO/8sqmQk04oaRdo17hCixfUcI+hcH+gFy7yU9LJa99hpIL3+CrEGrwfKhospnCcwyKwRbTJl3en
MlA/30wno9PFSdM5nJ+iQgfm6cryv05FcE7gagSg7HHvIMxQ5JIq0KGdMLIVVlZ/rFho=;
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x
;
h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:
In-Reply-To:Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc: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=LNnoBH/aVyGJ7WRg7LTaFXPb9tT6X+xdvFAcepflLG8=; b=BDbQDbP0NgrQ2pYl7R5q9PD3se
UXhvveUVnckYki/+bhiobHq/MvZ5q1yFvBHf5b6TqgW+5UBN2Qu0bd8K2R7CuJ1jc2wiFrLfcBpsR
N3kSrCT+Zu3XOmHvmEntWn0P2QxnZ8S4nYhrnXJjVJXDKSmAu47CIyNnSourYrakspm0=;
Received: from mout-p-102.mailbox.org ([80.241.56.152])
by sfi-mx-2.v28.lw.sourceforge.com with esmtps
(TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95)
id 1phRjo-0006Nv-Im for openvpn-devel@lists.sourceforge.net;
Wed, 29 Mar 2023 09:05:02 +0000
Received: from smtp102.mailbox.org (smtp102.mailbox.org
[IPv6:2001:67c:2050:b231:465::102])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest
SHA256) (No client certificate requested)
by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4Pmgc023bnz9scb
for <openvpn-devel@lists.sourceforge.net>;
Wed, 29 Mar 2023 11:04:48 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lichtenheld.com;
s=MBO0001; t=1680080688;
h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
to:to:cc:mime-version:mime-version:content-type:content-type:
content-transfer-encoding:content-transfer-encoding:
in-reply-to:in-reply-to:references:references;
bh=LNnoBH/aVyGJ7WRg7LTaFXPb9tT6X+xdvFAcepflLG8=;
b=JZ9Z18PrABB3uxyZTtfsjyadf3r7+rzmnTI6pRX3hljH3fnQZl/WKCMovPnrEeXZH1Odm5
Ne6JuHwceHBZlvBWAKoAP4kpkbbRKIL6uMgoAQMDWag39Y4Zh8whXNx6LJ8RmkazCJXZo2
125v70ah5hBjJCg6WPHPPAfawEo3/60CkPRPVyZvHKlf0fWeKCVD/NBa485sihiUfJF7Co
xaf/7JrZOWfCdtZkCloUs7Kw3nppd9xlOHfJraqnHwJF+KyMh0ttOF+Qk6YYq688vZxX21
o3qWxU/1JtFlC9RCsAtNjR81zhVUUAos6TaUjXgcvE/ZfTCaGWbvZWGuOA0ZDw==
From: Frank Lichtenheld <frank@lichtenheld.com>
To: openvpn-devel@lists.sourceforge.net
Date: Wed, 29 Mar 2023 11:04:46 +0200
Message-Id: <20230329090447.246561-1-frank@lichtenheld.com>
In-Reply-To: <20230328151233.217296-1-frank@lichtenheld.com>
References: <20230328151233.217296-1-frank@lichtenheld.com>
MIME-Version: 1.0
X-Rspamd-Queue-Id: 4Pmgc023bnz9scb
X-Spam-Score: -0.9 (/)
X-Spam-Report: Spam detection software,
running on the system "util-spamd-2.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: Since we use strlen() to determine the length and then check
it ourselves, there is really no point in using strncpy. But the compiler
might complain that we use the output of strlen() for the length of strncpy
which is usually a sign for bugs:
Content analysis details: (-0.9 points, 6.0 required)
pts rule name description
---- ----------------------
--------------------------------------------------
-0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/,
low trust [80.241.56.152 listed in list.dnswl.org]
-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 Message has at least one valid DKIM or DK signature
-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_SIGNED Message has a DKIM or DK signature,
not necessarily
valid
X-Headers-End: 1phRjo-0006Nv-Im
Subject: [Openvpn-devel] [PATCH 1/2 v2] buffer: use memcpy in buf_catrunc
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>
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: base64
Errors-To: openvpn-devel-bounces@lists.sourceforge.net
X-getmail-retrieved-from-mailbox: Inbox
X-GMAIL-THRID: =?utf-8?q?1761624870130583212?=
X-GMAIL-MSGID: =?utf-8?q?1761692343651220109?=
|
| Series |
[Openvpn-devel,1/2,v2] buffer: use memcpy in buf_catrunc
|
expand
|
diff --git a/src/openvpn/buffer.c b/src/openvpn/buffer.c index d099795b..886eb2c3 100644 --- a/src/openvpn/buffer.c +++ b/src/openvpn/buffer.c @@ -316,10 +316,10 @@ buf_catrunc(struct buffer *buf, const char *str) { if (buf_forward_capacity(buf) <= 1) { - int len = (int) strlen(str) + 1; + size_t len = strlen(str); if (len < buf_forward_capacity_total(buf)) { - strncpynt((char *)(buf->data + buf->capacity - len), str, len); + memcpy(buf->data + buf->capacity - len - 1, str, len + 1); } } }
Since we use strlen() to determine the length and then check it ourselves, there is really no point in using strncpy. But the compiler might complain that we use the output of strlen() for the length of strncpy which is usually a sign for bugs: error: ‘strncpy’ specified bound depends on the length of the source argument [-Werror=stringop-overflow=] Warning was at least triggered for mingw-gcc version 10-win32 20220113. Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com> --- src/openvpn/buffer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) v2: - make len size_t and change code to avoid any theoretical overflows - remove useless casts