Skip to content

Commit

Permalink
cgroup: use strscpy() is more robust and safer
Browse files Browse the repository at this point in the history
The implementation of strscpy() is more robust and safer.

That's now the recommended way to copy NUL terminated strings.

Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
Signed-off-by: Tejun Heo <tj@kernel.org>
  • Loading branch information
ye xingchen authored and Tejun Heo committed Sep 24, 2022
1 parent b74440d commit 8619e94
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion kernel/cgroup/cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -2374,7 +2374,7 @@ int task_cgroup_path(struct task_struct *task, char *buf, size_t buflen)
ret = cgroup_path_ns_locked(cgrp, buf, buflen, &init_cgroup_ns);
} else {
/* if no hierarchy exists, everyone is in "/" */
ret = strlcpy(buf, "/", buflen);
ret = strscpy(buf, "/", buflen);
}

spin_unlock_irq(&css_set_lock);
Expand Down

0 comments on commit 8619e94

Please sign in to comment.