Skip to content

Commit a3b2c8c

Browse files
minipligregkh
authored andcommitted
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 <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 3a76e5e commit a3b2c8c

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

fs/debugfs/file.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,7 @@ static ssize_t write_file_bool(struct file *file, const char __user *user_buf,
473473
if (copy_from_user(buf, user_buf, buf_size))
474474
return -EFAULT;
475475

476+
buf[buf_size] = '\0';
476477
if (strtobool(buf, &bv) == 0)
477478
*val = bv;
478479

0 commit comments

Comments
 (0)