[PATCH 1/4] proc_loginuid_write() uses simple_strtoul() on non-terminated array

Alexander Viro aviro at redhat.com
Fri May 19 21:32:47 UTC 2006


Signed-off-by: Al Viro <viro at zeniv.linux.org.uk>

---

 fs/proc/base.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

b464a96dd7aae91ac0399d93f7cb2fbb6dfc3dfe
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 6cc77dc..6afff72 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -1019,8 +1019,8 @@ static ssize_t proc_loginuid_write(struc
 	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(struc
 	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;
-- 
1.3.GIT




More information about the Linux-audit mailing list