diff options
author | Roland McGrath <roland@gnu.org> | 1996-01-30 22:04:27 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 1996-01-30 22:04:27 +0000 |
commit | 4e1533adc2a37bcd35f54a8ac505a2b4dc1a13db (patch) | |
tree | 4f50cc7f58a886ff64e2af95494d484bdb29fe9a /ext2fs | |
parent | efbc7feb4df3b1f33c2ba7b8606be5423172a463 (diff) |
(file_pager_read_page, file_pager_write_page): Check for a page offset
beyond the allocsize and return EIO.
Diffstat (limited to 'ext2fs')
-rw-r--r-- | ext2fs/pager.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/ext2fs/pager.c b/ext2fs/pager.c index e9131304..c387fe1f 100644 --- a/ext2fs/pager.c +++ b/ext2fs/pager.c @@ -114,7 +114,12 @@ file_pager_read_page (struct node *node, vm_offset_t page, return 0; } - if (page + left > node->allocsize) + if (page >= node->allocsize) + { + err = EIO; + left = 0; + } + else if (page + left > node->allocsize) left = node->allocsize - page; while (left > 0) @@ -134,7 +139,7 @@ file_pager_read_page (struct node *node, vm_offset_t page, } if (block == 0) - /* Reading unallocate block, just make a zero-filled one. */ + /* Reading unallocated block, just make a zero-filled one. */ { *writelock = 1; if (offs == 0) @@ -260,7 +265,12 @@ file_pager_write_page (struct node *node, vm_offset_t offset, vm_address_t buf) pending_blocks_init (&pb, buf); - if (offset + left > node->allocsize) + if (offset >= node->allocsize) + { + err = EIO; + left = 0; + } + else if (offset + left > node->allocsize) left = node->allocsize - offset; ext2_debug ("writing inode %d page %d[%d]", node->dn->number, offset, left); |