Merge branch 'akpm' (patches from Andrew)
[sfrench/cifs-2.6.git] / fs / exec.c
index 82db656ca709d6f1d4ef982181086c1a62b94a2c..3c3c366a9bcf581d718515409ad169e87ec46c5c 100644 (file)
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1207,7 +1207,8 @@ static int unshare_sighand(struct task_struct *me)
 char *__get_task_comm(char *buf, size_t buf_size, struct task_struct *tsk)
 {
        task_lock(tsk);
-       strncpy(buf, tsk->comm, buf_size);
+       /* Always NUL terminated and zero-padded */
+       strscpy_pad(buf, tsk->comm, buf_size);
        task_unlock(tsk);
        return buf;
 }
@@ -1222,7 +1223,7 @@ void __set_task_comm(struct task_struct *tsk, const char *buf, bool exec)
 {
        task_lock(tsk);
        trace_task_rename(tsk, buf);
-       strlcpy(tsk->comm, buf, sizeof(tsk->comm));
+       strscpy_pad(tsk->comm, buf, sizeof(tsk->comm));
        task_unlock(tsk);
        perf_event_comm(tsk, exec);
 }