mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
Bluetooth: bnep: refactor deprecated strcpy
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> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
parent
8b431b664d
commit
16ed10be23
|
|
@ -685,7 +685,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;
|
||||
|
||||
|
|
@ -727,7 +727,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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user