drivers/misc/enclosure: Replace strcpy() + strcat() with snprintf()

While the sizeof the target buffer is (should be) ENCLOSURE_NAME_SIZE
and the copies should not overrrun this stops any static analysis objecting
to the unbounded strcpy() and strcat() calls

Signed-off-by: David Laight <david.laight.linux@gmail.com>
Link: https://patch.msgid.link/20260608095523.2606-18-david.laight.linux@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
David Laight
2026-07-17 15:49:07 +02:00
committed by Greg Kroah-Hartman
parent 61b101c6a1
commit 6994c8b4ef
+2 -2
View File
@@ -184,8 +184,8 @@ EXPORT_SYMBOL_GPL(enclosure_unregister);
static void enclosure_link_name(struct enclosure_component *cdev, char *name)
{
strcpy(name, "enclosure_device:");
strcat(name, dev_name(&cdev->cdev));
snprintf(name, ENCLOSURE_NAME_SIZE, "enclosure_device:%s",
dev_name(&cdev->cdev));
}
static void enclosure_remove_links(struct enclosure_component *cdev)