Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=8d06087714b78e8921bd30b5c64202fe80c47339
Commit:     8d06087714b78e8921bd30b5c64202fe80c47339
Parent:     c75fb88dbcc470e6041a20b1457b4835b9a0a48a
Author:     Oleg Nesterov <[EMAIL PROTECTED]>
AuthorDate: Sat Feb 10 01:46:38 2007 -0800
Committer:  Linus Torvalds <[EMAIL PROTECTED]>
CommitDate: Sun Feb 11 11:18:07 2007 -0800

    [PATCH] _proc_do_string(): fix short reads
    
    If you try to read things like /proc/sys/kernel/osrelease with single-byte
    reads, you get just one byte and then EOF.  This is because 
_proc_do_string()
    assumes that the caller is read()ing into a buffer which is large enough to
    fit the whole string in a single hit.
    
    Fix.
    
    Cc: "Eric W. Biederman" <[EMAIL PROTECTED]>
    Cc: Michael Tokarev <[EMAIL PROTECTED]>
    Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
    Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
---
 kernel/sysctl.c |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 84cab0c..e0ac6cd 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -1686,13 +1686,12 @@ static int _proc_do_string(void* data, int maxlen, int 
write,
        size_t len;
        char __user *p;
        char c;
-       
-       if (!data || !maxlen || !*lenp ||
-           (*ppos && !write)) {
+
+       if (!data || !maxlen || !*lenp) {
                *lenp = 0;
                return 0;
        }
-       
+
        if (write) {
                len = 0;
                p = buffer;
@@ -1713,6 +1712,15 @@ static int _proc_do_string(void* data, int maxlen, int 
write,
                len = strlen(data);
                if (len > maxlen)
                        len = maxlen;
+
+               if (*ppos > len) {
+                       *lenp = 0;
+                       return 0;
+               }
+
+               data += *ppos;
+               len  -= *ppos;
+
                if (len > *lenp)
                        len = *lenp;
                if (len)
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to