Skip to contentSkip to conversation

tsacct: Replace strncpy() with strscpy()

PATCH Applied Kees Cook 1 participant 1 message Jul 11, 2024

lore
Share & tools
lore

Kees Cook

author
#0 lore raw

PATCH 1/1 tsacct: Replace strncpy() with strscpy()

Replace the deprecated[1] use of strncpy() in bacct_add_tsk(). Since this is UAPI, include trailing padding in the copy.

---
Cc: Andrew Morton <[email protected]>
Cc: "Eric W. Biederman" <[email protected]>
Cc: Peng Liu <[email protected]>
Cc: "Dr. Thomas Orgis" <[email protected]>
Cc: Ismael Luceno <[email protected]>

---
 kernel/tsacct.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/tsacct.c +1 -1
index 4252f0645b9e..16b283f9d831 100644
@@ -76,7 +76,7 @@ void bacct_add_tsk(struct user_namespace *user_ns,
 	stats->ac_minflt = tsk->min_flt;
 	stats->ac_majflt = tsk->maj_flt;
 
-	strncpy(stats->ac_comm, tsk->comm, sizeof(stats->ac_comm));
+	strscpy_pad(stats->ac_comm, tsk->comm);
 }
 
 
Signature · 1 line
2.34.1