From 98807de9ac11a11a352f148e66e32d781f22c114 Mon Sep 17 00:00:00 2001 From: Thorsten Blum Date: Sat, 26 Sep 2026 07:58:55 +0200 Subject: [PATCH] hwrng: virtio - use snprintf() in probe_common() While the current code works correctly, replace the unbounded sprintf() with the safer snprintf() to follow secure coding best practices. Signed-off-by: Thorsten Blum Reviewed-by: Thomas Huth Reviewed-by: Laurent Vivier Signed-off-by: Herbert Xu --- drivers/char/hw_random/virtio-rng.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/char/hw_random/virtio-rng.c b/drivers/char/hw_random/virtio-rng.c index 5b1b23b5596a..f9982217247d 100644 --- a/drivers/char/hw_random/virtio-rng.c +++ b/drivers/char/hw_random/virtio-rng.c @@ -162,7 +162,7 @@ static int probe_common(struct virtio_device *vdev) err = index; goto err_ida; } - sprintf(vi->name, "virtio_rng.%d", index); + snprintf(vi->name, sizeof(vi->name), "virtio_rng.%d", vi->index); init_completion(&vi->have_data); vi->hwrng = (struct hwrng) {