From a3b2c8c7aa1ca860edcf0b0afa371d9eb2269c3c Mon Sep 17 00:00:00 2001 From: Mathias Krause Date: Fri, 31 May 2013 23:24:29 +0200 Subject: debugfs: write_file_bool() - ensure strtobool() operates on valid data In case, userland writes an empty string to a bool debugfs file, buf[] will still be uninitialized when being passed to strtobool() making the outcome of that function purely random. Fix this by always zero-terminating the buffer. Signed-off-by: Mathias Krause Signed-off-by: Greg Kroah-Hartman --- fs/debugfs/file.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c index ff64bcd5b8fb..63146295153b 100644 --- a/fs/debugfs/file.c +++ b/fs/debugfs/file.c @@ -473,6 +473,7 @@ static ssize_t write_file_bool(struct file *file, const char __user *user_buf, if (copy_from_user(buf, user_buf, buf_size)) return -EFAULT; + buf[buf_size] = '\0'; if (strtobool(buf, &bv) == 0) *val = bv; -- cgit v1.2.1