[PATCH] sandbox: eth-raw: Prevent possible buffer overflow

Andrew Goodbody andrew.goodbody at linaro.org
Thu Jul 17 13:09:15 CEST 2025


Instead of strcpy which is unbounded use strlcpy to ensure that the
receiving buffer cannot be overflowed.

This issue found by Smatch.

Signed-off-by: Andrew Goodbody <andrew.goodbody at linaro.org>
---
 drivers/net/sandbox-raw-bus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/sandbox-raw-bus.c b/drivers/net/sandbox-raw-bus.c
index 15670d6d24a..c698a07c784 100644
--- a/drivers/net/sandbox-raw-bus.c
+++ b/drivers/net/sandbox-raw-bus.c
@@ -42,7 +42,7 @@ static int eth_raw_bus_post_bind(struct udevice *dev)
 		device_probe(child);
 		priv = dev_get_priv(child);
 		if (priv) {
-			strcpy(priv->host_ifname, i->if_name);
+			strlcpy(priv->host_ifname, i->if_name, IFNAMSIZ);
 			priv->host_ifindex = i->if_index;
 			priv->local = local;
 		}

---
base-commit: 3b4604a40b9fd61b87e9d059fc56f04d36f1a380
change-id: 20250717-sandbox-raw-ea339a2554ce

Best regards,
-- 
Andrew Goodbody <andrew.goodbody at linaro.org>



More information about the U-Boot mailing list