[openwrt/openwrt] realtek: ethernet: Avoid usage of unsafe strcpy

LEDE Commits lede-commits at lists.infradead.org
Mon Nov 24 15:30:01 PST 2025


hauke pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/80375e5acdaaf7555cd44ee1c8f247f701c6c5cb

commit 80375e5acdaaf7555cd44ee1c8f247f701c6c5cb
Author: Sven Eckelmann <sven at narfation.org>
AuthorDate: Sun Nov 23 15:10:41 2025 +0100

    realtek: ethernet: Avoid usage of unsafe strcpy
    
    strcpy doesn't check the length of the destination buffer. And strlcpy
    would not make sure to null-terminate the destination buffer.
    
    Even when it is clear that this string will fit in the currrent buffer, it
    is just best practice to avoid strcpy.
    
    Signed-off-by: Sven Eckelmann <sven at narfation.org>
    Link: https://github.com/openwrt/openwrt/pull/20906
    Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
---
 target/linux/realtek/files-6.12/drivers/net/ethernet/rtl838x_eth.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/target/linux/realtek/files-6.12/drivers/net/ethernet/rtl838x_eth.c b/target/linux/realtek/files-6.12/drivers/net/ethernet/rtl838x_eth.c
index d9c0fb16a3..91ea29d6c0 100644
--- a/target/linux/realtek/files-6.12/drivers/net/ethernet/rtl838x_eth.c
+++ b/target/linux/realtek/files-6.12/drivers/net/ethernet/rtl838x_eth.c
@@ -1798,7 +1798,8 @@ static int __init rtl838x_eth_probe(struct platform_device *pdev)
 	}
 	pr_info("Using MAC %08x%08x\n", sw_r32(priv->r->mac),
 					sw_r32(priv->r->mac + 4));
-	strcpy(dev->name, "eth%d");
+	strscpy(dev->name, "eth%d", sizeof(dev->name));
+
 	priv->pdev = pdev;
 	priv->netdev = dev;
 




More information about the lede-commits mailing list