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;