From 963f35e96d9ae16d9e3a66a2760bd5c8138cf211 Mon Sep 17 00:00:00 2001 From: liuduanfei <939763442@qq.com> Date: Fri, 18 Dec 2020 20:53:33 +0800 Subject: [PATCH] Update netdev.c --- components/net/netdev/src/netdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/net/netdev/src/netdev.c b/components/net/netdev/src/netdev.c index 04bf6e8ad7..92d5b188eb 100644 --- a/components/net/netdev/src/netdev.c +++ b/components/net/netdev/src/netdev.c @@ -78,7 +78,7 @@ int netdev_register(struct netdev *netdev, const char *name, void *user_data) netdev->addr_callback = RT_NULL; /* fill network interface device */ - rt_strncpy(netdev->name, name, rt_strlen(name)); + rt_strncpy(netdev->name, name, RT_NAME_MAX); netdev->user_data = user_data; /* initialize current network interface device single list */ @@ -260,7 +260,7 @@ struct netdev *netdev_get_by_name(const char *name) for (node = &(netdev_list->list); node; node = rt_slist_next(node)) { netdev = rt_slist_entry(node, struct netdev, list); - if (netdev && (rt_strncmp(netdev->name, name, rt_strlen(netdev->name)) == 0)) + if (netdev && (rt_strncmp(netdev->name, name, RT_NAME_MAX) == 0)) { rt_hw_interrupt_enable(level); return netdev;