diff options
Diffstat (limited to 'fs/proc')
-rw-r--r-- | fs/proc/base.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c index a19308604145..3861bcec41ff 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -1348,11 +1348,10 @@ static ssize_t comm_write(struct file *file, const char __user *buf, struct inode *inode = file_inode(file); struct task_struct *p; char buffer[TASK_COMM_LEN]; + const size_t maxlen = sizeof(buffer) - 1; memset(buffer, 0, sizeof(buffer)); - if (count > sizeof(buffer) - 1) - count = sizeof(buffer) - 1; - if (copy_from_user(buffer, buf, count)) + if (copy_from_user(buffer, buf, count > maxlen ? maxlen : count)) return -EFAULT; p = get_proc_task(inode); |