Skip to contentSkip to conversation

wifi: cfg80211: use strscpy in cfg80211_wext_giwname

PATCH New Thorsten Blum 1 participant 1 message May 28 802.11 (including cfg80211/NL80211)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 wifi: cfg80211: use strscpy in cfg80211_wext_giwname

strcpy() has been deprecated [1] because it performs no bounds checking on the destination buffer, which can lead to buffer overflows.

While the current code works correctly, replace strcpy() with the safer strscpy() to follow secure coding best practices.

[1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy

---
 net/wireless/wext-compat.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/wireless/wext-compat.c +2 -1
index 1241fda78a68..1d6c60d3ad5b 100644
@@ -16,6 +16,7 @@
 #include <linux/if_arp.h>
 #include <linux/etherdevice.h>
 #include <linux/slab.h>
+#include <linux/string.h>
 #include <net/iw_handler.h>
 #include <net/cfg80211.h>
 #include <net/cfg80211-wext.h>
@@ -27,7 +28,7 @@ int cfg80211_wext_giwname(struct net_device *dev,
 			  struct iw_request_info *info,
 			  union iwreq_data *wrqu, char *extra)
 {
-	strcpy(wrqu->name, "IEEE 802.11");
+	strscpy(wrqu->name, "IEEE 802.11");
 	return 0;
 }