public inbox for linux-kernel-mentees@lists.linux-foundation.org
 help / color / mirror / Atom feed
* [RFC PATCH] wifi: mac80211: Replace strncpy() with strscpy()
@ 2025-03-27 14:11 I Hsin Cheng
  2025-03-27 14:24 ` I Hsin Cheng
  2025-03-28  9:26 ` Johannes Berg
  0 siblings, 2 replies; 3+ messages in thread
From: I Hsin Cheng @ 2025-03-27 14:11 UTC (permalink / raw)
  To: johannes
  Cc: linux-wireless, linux-kernel, skhan, linux-kernel-mentees,
	I Hsin Cheng

The name of vif which is "vif_name" should be NULL-terminated to be a
valid string, however "strncpy()" doesn't guarantee that. Replace it
with "strscpy()" to make sure the content within "vif_name" is
NULL-terminated.

Link: https://github.com/KSPP/linux/issues/90
Signed-off-by: I Hsin Cheng <richard120310@gmail.com>
---
 net/mac80211/trace.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/mac80211/trace.h b/net/mac80211/trace.h
index 72fad8ea8bb9..37f5b1c87709 100644
--- a/net/mac80211/trace.h
+++ b/net/mac80211/trace.h
@@ -1725,7 +1725,7 @@ TRACE_EVENT(drv_switch_vif_chanctx,
 				SWITCH_ENTRY_ASSIGN(vif.vif_type, vif->type);
 				SWITCH_ENTRY_ASSIGN(vif.p2p, vif->p2p);
 				SWITCH_ENTRY_ASSIGN(link_id, link_conf->link_id);
-				strncpy(local_vifs[i].vif.vif_name,
+				strscpy(local_vifs[i].vif.vif_name,
 					sdata->name,
 					sizeof(local_vifs[i].vif.vif_name));
 				SWITCH_ENTRY_ASSIGN(old_chandef.control_freq,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-03-28  9:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-27 14:11 [RFC PATCH] wifi: mac80211: Replace strncpy() with strscpy() I Hsin Cheng
2025-03-27 14:24 ` I Hsin Cheng
2025-03-28  9:26 ` Johannes Berg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox