From: Al Viro Date: Thu, 18 May 2006 12:28:02 +0000 (-0400) Subject: [PATCH] proc_loginuid_write() uses simple_strtoul() on non-terminated array X-Git-Tag: v2.6.18-rc1~1102^2~9 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e0182909297da8d38a5d473ae7bee3d0324632a1;p=linux-2.6 [PATCH] proc_loginuid_write() uses simple_strtoul() on non-terminated array Signed-off-by: Al Viro --- diff --git a/fs/proc/base.c b/fs/proc/base.c index 6cc77dc3f3..6afff725a8 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -1019,8 +1019,8 @@ static ssize_t proc_loginuid_write(struct file * file, const char __user * buf, if (current != task) return -EPERM; - if (count > PAGE_SIZE) - count = PAGE_SIZE; + if (count >= PAGE_SIZE) + count = PAGE_SIZE - 1; if (*ppos != 0) { /* No partial writes. */ @@ -1033,6 +1033,7 @@ static ssize_t proc_loginuid_write(struct file * file, const char __user * buf, if (copy_from_user(page, buf, count)) goto out_free_page; + page[count] = '\0'; loginuid = simple_strtoul(page, &tmp, 10); if (tmp == page) { length = -EINVAL;