[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <11650154221716-git-send-email-greg@kroah.com>
Date: Fri, 1 Dec 2006 15:21:59 -0800
From: Greg KH <greg@...ah.com>
To: linux-kernel@...r.kernel.org
Cc: Thomas Maier <balagi@...tmail.de>,
Greg Kroah-Hartman <gregkh@...e.de>
Subject: [PATCH 29/36] sysfs: sysfs_write_file() writes zero terminated data
From: Thomas Maier <balagi@...tmail.de>
since most of the files in sysfs are text files,
it would be nice, if the "store" function called
during sysfs_write_file() gets a zero terminated
string / data.
The current implementation seems not to ensure this.
(But only if it is the first time the zeroed buffer
page is allocated.)
So the buffer can be scanned by sscanf() easily,
for example.
This patch simply sets a \0 char behind the
data in buffer->page.
Signed-off-by: Thomas Maier <balagi@...tmail.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@...e.de>
---
fs/sysfs/file.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index 298303b..95c1651 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -190,6 +190,9 @@ fill_write_buffer(struct sysfs_buffer *
count = PAGE_SIZE - 1;
error = copy_from_user(buffer->page,buf,count);
buffer->needs_read_fill = 1;
+ /* if buf is assumed to contain a string, terminate it by \0,
+ so e.g. sscanf() can scan the string easily */
+ buffer->page[count] = 0;
return error ? -EFAULT : count;
}
--
1.4.4.1
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists