From: Justin Stitt <justinstitt@google.com>
To: Pablo Neira Ayuso <pablo@netfilter.org>,
Jozsef Kadlecsik <kadlec@netfilter.org>,
Florian Westphal <fw@strlen.de>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: linux-hardening@vger.kernel.org,
Kees Cook <keescook@chromium.org>,
netfilter-devel@vger.kernel.org, coreteam@netfilter.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Justin Stitt <justinstitt@google.com>
Subject: [PATCH 5/7] netfilter: nft_osf: refactor deprecated strncpy to strscpy
Date: Tue, 08 Aug 2023 22:48:10 +0000 [thread overview]
Message-ID: <20230808-net-netfilter-v1-5-efbbe4ec60af@google.com> (raw)
In-Reply-To: <20230808-net-netfilter-v1-0-efbbe4ec60af@google.com>
Use `strscpy` over `strncpy` for NUL-terminated strings.
We can also drop the + 1 from `NFT_OSF_MAXGENRELEN + 1` since `strscpy`
will guarantee NUL-termination.
Signed-off-by: Justin Stitt <justinstitt@google.com>
---
net/netfilter/nft_osf.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/net/netfilter/nft_osf.c b/net/netfilter/nft_osf.c
index 70820c66b591..4844e0109a58 100644
--- a/net/netfilter/nft_osf.c
+++ b/net/netfilter/nft_osf.c
@@ -23,7 +23,7 @@ static void nft_osf_eval(const struct nft_expr *expr, struct nft_regs *regs,
struct nft_osf *priv = nft_expr_priv(expr);
u32 *dest = ®s->data[priv->dreg];
struct sk_buff *skb = pkt->skb;
- char os_match[NFT_OSF_MAXGENRELEN + 1];
+ char os_match[NFT_OSF_MAXGENRELEN];
const struct tcphdr *tcp;
struct nf_osf_data data;
struct tcphdr _tcph;
@@ -45,7 +45,7 @@ static void nft_osf_eval(const struct nft_expr *expr, struct nft_regs *regs,
}
if (!nf_osf_find(skb, nf_osf_fingers, priv->ttl, &data)) {
- strncpy((char *)dest, "unknown", NFT_OSF_MAXGENRELEN);
+ strscpy((char *)dest, "unknown", NFT_OSF_MAXGENRELEN);
} else {
if (priv->flags & NFT_OSF_F_VERSION)
snprintf(os_match, NFT_OSF_MAXGENRELEN, "%s:%s",
@@ -53,7 +53,7 @@ static void nft_osf_eval(const struct nft_expr *expr, struct nft_regs *regs,
else
strscpy(os_match, data.genre, NFT_OSF_MAXGENRELEN);
- strncpy((char *)dest, os_match, NFT_OSF_MAXGENRELEN);
+ strscpy((char *)dest, os_match, NFT_OSF_MAXGENRELEN);
}
}
--
2.41.0.640.ga95def55d0-goog
next prev parent reply other threads:[~2023-08-08 22:48 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-08 22:48 [PATCH 0/7] netfilter: refactor deprecated strncpy Justin Stitt
2023-08-08 22:48 ` [PATCH 1/7] netfilter: ipset: " Justin Stitt
2023-08-08 23:38 ` Florian Westphal
2023-08-09 0:00 ` Kees Cook
2023-08-08 22:48 ` [PATCH 2/7] netfilter: nf_tables: " Justin Stitt
2023-08-08 23:40 ` Florian Westphal
2023-08-09 0:41 ` Justin Stitt
2023-08-08 22:48 ` [PATCH 3/7] " Justin Stitt
2023-08-08 23:13 ` Florian Westphal
2023-08-08 22:48 ` [PATCH 4/7] netfilter: nft_meta: " Justin Stitt
2023-08-08 22:48 ` Justin Stitt [this message]
2023-08-08 22:48 ` [PATCH 6/7] netfilter: x_tables: " Justin Stitt
2023-08-08 23:57 ` Florian Westphal
2023-08-09 0:04 ` Kees Cook
2023-08-08 22:48 ` [PATCH 7/7] netfilter: xtables: " Justin Stitt
2023-08-08 23:20 ` Jan Engelhardt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230808-net-netfilter-v1-5-efbbe4ec60af@google.com \
--to=justinstitt@google.com \
--cc=coreteam@netfilter.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=fw@strlen.de \
--cc=kadlec@netfilter.org \
--cc=keescook@chromium.org \
--cc=kuba@kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pablo@netfilter.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).