From: Ajith P V <ajithpv.linux@gmail.com>
To: marcel@holtmann.org, luiz.dentz@gmail.com
Cc: linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org,
Ajith P V <ajithpv.linux@gmail.com>
Subject: [PATCH] Bluetooth: bnep: refactor deprecated strcpy
Date: Tue, 11 Aug 2026 09:49:32 +0000 [thread overview]
Message-ID: <20260811094932.86448-1-ajithpv.linux@gmail.com> (raw)
The strcpy() function is deprecated across the kernel tree and
moving towards complete elimination. It provides no verification
limits against buffer overflows and does not guarantee strict boundary
restrictions [1][2].
Replace instances of strcpy() in `net/bluetooth/bnep/core.c` with the safer
strscpy() alternative. Since both target destination blocks are
statically allocated fixed-size arrays within their structure definitions,
leverage the compile time sizeof() operator to explicitly pass the
destination buffer capacities.
Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy [1]
Link: https://github.com/KSPP/linux/issues/88 [2]
Signed-off-by: Ajith P V <ajithpv.linux@gmail.com>
---
net/bluetooth/bnep/core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/bluetooth/bnep/core.c b/net/bluetooth/bnep/core.c
index f7d88c33e23e..0dde82e9a085 100644
--- a/net/bluetooth/bnep/core.c
+++ b/net/bluetooth/bnep/core.c
@@ -670,7 +670,7 @@ int bnep_add_connection(struct bnep_connadd_req *req, struct socket *sock)
goto failed;
}
- strcpy(req->device, dev->name);
+ strscpy(req->device, dev->name, sizeof(req->device));
up_write(&bnep_session_sem);
return 0;
@@ -712,7 +712,7 @@ static void __bnep_copy_ci(struct bnep_conninfo *ci, struct bnep_session *s)
memset(ci, 0, sizeof(*ci));
memcpy(ci->dst, s->eh.h_source, ETH_ALEN);
- strcpy(ci->device, s->dev->name);
+ strscpy(ci->device, s->dev->name, sizeof(ci->device));
ci->flags = s->flags & valid_flags;
ci->state = s->state;
ci->role = s->role;
--
2.43.0
next reply other threads:[~2026-08-11 9:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-11 9:49 Ajith P V [this message]
2026-08-11 11:05 ` Bluetooth: bnep: refactor deprecated strcpy bluez.test.bot
2026-08-11 20:10 ` [PATCH] " patchwork-bot+bluetooth
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=20260811094932.86448-1-ajithpv.linux@gmail.com \
--to=ajithpv.linux@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
--cc=marcel@holtmann.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