Commit 72007d2d authored by Andrew Morton's avatar Andrew Morton Committed by Christoph Hellwig

[PATCH] proc_file_read fix

From: Miklos.Szeredi@eth.ericsson.se (Miklos Szeredi)

This fixes a problem with method 0 of proc_file_read (when the whole file
is copied to the page).  The calculation of the final bytecount is wrong,
and hence smaller then page size reads will give a truncated file.

Current 2.4 kernels do it this way as well.
parent 3bf1ad5d
...@@ -136,11 +136,11 @@ proc_file_read(struct file * file, char * buf, size_t nbytes, loff_t *ppos) ...@@ -136,11 +136,11 @@ proc_file_read(struct file * file, char * buf, size_t nbytes, loff_t *ppos)
"proc_file_read: Apparent buffer overflow!\n"); "proc_file_read: Apparent buffer overflow!\n");
n = PAGE_SIZE; n = PAGE_SIZE;
} }
if (n > count)
n = count;
n -= *ppos; n -= *ppos;
if (n <= 0) if (n <= 0)
break; break;
if (n > count)
n = count;
start = page + *ppos; start = page + *ppos;
} else if (start < page) { } else if (start < page) {
if (n > PAGE_SIZE) { if (n > PAGE_SIZE) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment