proc: fix unterminated string
Subsystems (2)
PATCH 1/1 proc: fix unterminated string
From: Alan Cox <[email protected]>
oom_score_adj_write doesn't terminate the string as it should. Also fix sched_autogroup_write and other copy/pastes of the bug.
Signed-off-by Alan Cox <[email protected]>
Cc Horses <[email protected]>
---
fs/proc/base.c | 2 ++ fs/proc/task_mmu.c | 1 + 2 files changed, 3 insertions(+)
fs/proc/base.c +2 -0
@@ -910,6 +910,7 @@ static ssize_t oom_score_adj_write(struct file *file, const char __user *buf, err = -EFAULT ; goto out; } + buffer[count] ='\0' ; err =kstrtoint (strstrip (buffer),0 , &oom_score_adj);if (err)
@@ -1192,6 +1193,7 @@ sched_autogroup_write(struct file *file, const char __user *buf, count =sizeof (buffer) -1 ;if (copy_from_user (buffer, buf, count))return -EFAULT ; + buffer[count] ='\0' ; err =kstrtoint (strstrip (buffer),0 , &nice);if (err <0 )
fs/proc/task_mmu.c +1 -0
@@ -639,6 +639,7 @@ static ssize_t clear_refs_write(struct file *file, const char __user *buf, count =sizeof (buffer) -1 ;if (copy_from_user (buffer, buf, count))return -EFAULT ; + buffer[count] ='\0' ; rv =kstrtoint (strstrip (buffer),10 , &type);if (rv <0 )return rv;
Quoted 7 lines · On Mon, 17 Sep 2012 11:49:30 +0100 Alan Cox <[email protected]> wrote:
From: Alan Cox <[email protected]>
oom_score_adj_writedoesn't terminate the string as it should. Also fixsched_autogroup_writeand other copy/pastes of the bug.Signed-off-by Alan Cox <[email protected]>Cc Horses <[email protected]>
Ok ignore this one - its in fact safe having poked at it further - the memset ensures the buffer is terminated. Ugly but the existing code works fine 8)