All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] debugfs: write_file_bool() - ensure strtobool() operates on valid data
@ 2013-05-31 21:24 Mathias Krause
  0 siblings, 0 replies; only message in thread
From: Mathias Krause @ 2013-05-31 21:24 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-kernel, Mathias Krause

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 <minipli@googlemail.com>
---
 fs/debugfs/file.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c
index c5ca6ae..b15a1c5 100644
--- a/fs/debugfs/file.c
+++ b/fs/debugfs/file.c
@@ -431,6 +431,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;
 
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2013-05-31 21:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-31 21:24 [PATCH] debugfs: write_file_bool() - ensure strtobool() operates on valid data Mathias Krause

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.