summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorSteve French <sfrench@us.ibm.com>2005-10-12 15:32:05 -0700
committerSteve French <sfrench@us.ibm.com>2005-10-12 15:32:05 -0700
commit84d2f07e8e5e2424eec0f5acfef6792c924a0549 (patch)
treec996a1a89db7124d4e644c6abe5e8f0f9c6fdab3 /fs
parent47c786e79b46ef478a1123cb57c711ecb481cbfa (diff)
CIFS: cifs_writepages should not write beyond end of file
Signed-off-by: Dave Kleikamp <shaggy@austin.ibm.com> Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/cifs/file.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 585a62aebd59..23af20d5af7c 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -1011,6 +1011,7 @@ static int cifs_writepages(struct address_space *mapping,
pgoff_t index;
int is_range = 0;
struct kvec iov[32];
+ int len;
int n_iov = 0;
pgoff_t next;
int nr_pages;
@@ -1124,16 +1125,26 @@ retry:
unlock_page(page);
break;
}
+
+ if (page_offset(page) >= mapping->host->i_size) {
+ done = 1;
+ unlock_page(page);
+ break;
+ }
+
/*
* BB can we get rid of this? pages are held by pvec
*/
page_cache_get(page);
+ len = min(mapping->host->i_size - page_offset(page),
+ (loff_t)PAGE_CACHE_SIZE);
+
/* reserve iov[0] for the smb header */
n_iov++;
iov[n_iov].iov_base = kmap(page);
- iov[n_iov].iov_len = PAGE_CACHE_SIZE;
- bytes_to_write += PAGE_CACHE_SIZE;
+ iov[n_iov].iov_len = len;
+ bytes_to_write += len;
if (first < 0) {
first = i;