summaryrefslogtreecommitdiff
path: root/libstore/rdwr.c
diff options
context:
space:
mode:
authorMarcus Brinkmann <marcus@gnu.org>2002-03-14 01:23:08 +0000
committerMarcus Brinkmann <marcus@gnu.org>2002-03-14 01:23:08 +0000
commitfba1ada51bdfa7fea872c2f6a0e8745584df22c0 (patch)
treea29496a07899ac93b9cc1d6d5f0dcba3d7dd68b3 /libstore/rdwr.c
parent9eccd96bdb880eb489b61959c9bbccf92425fc8a (diff)
2002-03-14 Marcus Brinkmann <marcus@gnu.org>
* rdwr.c (store_read): Truncate amount to be read to size of store. Use memcpy rather than bcopy. (store_write): Return EIO if caller tries to write over the end of the store. * copy.c (copy_read): Do not multiply LEN returned from vm_read with vm_page_size.
Diffstat (limited to 'libstore/rdwr.c')
-rw-r--r--libstore/rdwr.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/libstore/rdwr.c b/libstore/rdwr.c
index f6652a12..ecc604fe 100644
--- a/libstore/rdwr.c
+++ b/libstore/rdwr.c
@@ -1,6 +1,6 @@
/* Store I/O
- Copyright (C) 1995,96,97,98,99,2001 Free Software Foundation, Inc.
+ Copyright (C) 1995,96,97,98,99,2001,02 Free Software Foundation, Inc.
Written by Miles Bader <miles@gnu.org>
This file is part of the GNU Hurd.
@@ -107,6 +107,9 @@ store_write (struct store *store,
if (store->flags & STORE_READONLY)
return EROFS; /* XXX */
+ if ((addr << block_shift) + len > store->size)
+ return EIO;
+
if (store->block_size != 0)
assert ((len & (store->block_size - 1)) == 0);
@@ -184,6 +187,9 @@ store_read (struct store *store,
if (addr < 0 || run->start < 0)
return EIO; /* Reading from a hole. */
+ if ((addr << block_shift) + amount > store->size)
+ amount = store->size - (addr << block_shift);
+
if (store->block_size != 0)
assert ((amount & (store->block_size - 1)) == 0);
@@ -215,11 +221,11 @@ store_read (struct store *store,
if (!err)
{
/* If for some bizarre reason, the underlying storage chose not
- to use the buffer space we so kindly gave it, bcopy it to
+ to use the buffer space we so kindly gave it, copy it to
that space. */
if (seg_buf != buf_end)
{
- bcopy (seg_buf, buf_end, seg_buf_len);
+ memcpy (buf_end, seg_buf, seg_buf_len);
munmap (seg_buf, seg_buf_len);
}
buf_end += seg_buf_len;