On Wed, Dec 13, 2023 at 09:18:40AM +0800, xueqin Luo wrote: > `strncpy` is deprecated for use on NUL-terminated destination strings > [1] and as such we should prefer more robust and less ambiguous string > interfaces. > > We should NUL-pad as there are full struct copies happening in places: > | case NL80211_IFTYPE_MONITOR: > | ret = rtw_cfg80211_add_monitor_if(padapter, > | (char *)name, &ndev); > | break; > I don't see where the full copy is... What you're looking for is some place that copies "mon_ndev->name" to the user. > A suitable replacement is `strscpy_pad` due to the fact that it > guarantees both NUL-termination and NUL-padding on the destination > buffer. > > Additionally, replace size macro `IFNAMSIZ` with sizeof(): > | struct net_device { > | char name[IFNAMSIZ]; > | ... This would normally be the right move but IFNAMSIZ is a really standard macro that everyone knows. When I'm reviewing this code, I later on see a line: memcpy(pwdev_priv->ifname_mon, name, IFNAMSIZ + 1); That means name must be "IFNAMSIZ + 1" characters long or it is a bug. Please find out where name is set. We need to know how long it is before we can go any further. regards, dan carpenter