From: Ethan Carter Edwards <ethan@ethancedwards.com>
To: Oliver Hartkopp <socketcan@hartkopp.net>,
Marc Kleine-Budde <mkl@pengutronix.de>
Cc: linux-can@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-hardening@vger.kernel.org,
kernel-janitors@vger.kernel.org,
Ethan Carter Edwards <ethan@ethancedwards.com>
Subject: [PATCH] can: bcm: Replace strcpy() with strscpy(), simplify call
Date: Sat, 18 Apr 2026 22:00:13 -0400 [thread overview]
Message-ID: <20260418-can-bcm-strscpy-v1-1-993eb8de9f77@ethancedwards.com> (raw)
strcpy() is deprecated; use the safer strscpy() instead.
While the src is char array at bcm_proc_getifname's call sites, the src
is passed to the function as a char*. Including the IFNAMSIZ length
makes the call safer.
Use turnary over if/else to simplify code.
Link: https://github.com/KSPP/linux/issues/88
Signed-off-by: Ethan Carter Edwards <ethan@ethancedwards.com>
---
net/can/bcm.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/net/can/bcm.c b/net/can/bcm.c
index a4bef2c48a55..c133dab1202e 100644
--- a/net/can/bcm.c
+++ b/net/can/bcm.c
@@ -196,10 +196,7 @@ static char *bcm_proc_getifname(struct net *net, char *result, int ifindex)
rcu_read_lock();
dev = dev_get_by_index_rcu(net, ifindex);
- if (dev)
- strcpy(result, dev->name);
- else
- strcpy(result, "???");
+ strscpy(result, dev ? dev->name : "???", IFNAMSIZ);
rcu_read_unlock();
return result;
---
base-commit: c7275b05bc428c7373d97aa2da02d3a7fa6b9f66
change-id: 20260418-can-bcm-strscpy-56a0e402a660
Best regards,
--
Ethan Carter Edwards <ethan@ethancedwards.com>
next reply other threads:[~2026-04-19 2:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-19 2:00 Ethan Carter Edwards [this message]
2026-04-19 2:18 ` Ethan Carter Edwards
2026-04-20 10:33 ` Oliver Hartkopp
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=20260418-can-bcm-strscpy-v1-1-993eb8de9f77@ethancedwards.com \
--to=ethan@ethancedwards.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-can@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mkl@pengutronix.de \
--cc=socketcan@hartkopp.net \
/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
all inboxes | Powered by JetHome®