diff options
author | Marcus Brinkmann <marcus@gnu.org> | 2002-03-14 01:23:08 +0000 |
---|---|---|
committer | Marcus Brinkmann <marcus@gnu.org> | 2002-03-14 01:23:08 +0000 |
commit | fba1ada51bdfa7fea872c2f6a0e8745584df22c0 (patch) | |
tree | a29496a07899ac93b9cc1d6d5f0dcba3d7dd68b3 | |
parent | 9eccd96bdb880eb489b61959c9bbccf92425fc8a (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.
-rw-r--r-- | libstore/ChangeLog | 9 | ||||
-rw-r--r-- | libstore/copy.c | 14 | ||||
-rw-r--r-- | libstore/rdwr.c | 12 |
3 files changed, 23 insertions, 12 deletions
diff --git a/libstore/ChangeLog b/libstore/ChangeLog index 4e3c400f..1c235cd2 100644 --- a/libstore/ChangeLog +++ b/libstore/ChangeLog @@ -1,3 +1,12 @@ +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. + 2002-03-11 Marcus Brinkmann <marcus@gnu.org> * stripe.c (store_concat_class): Add store_concat_open. diff --git a/libstore/copy.c b/libstore/copy.c index a984fbd2..4e1cf0d4 100644 --- a/libstore/copy.c +++ b/libstore/copy.c @@ -1,6 +1,6 @@ /* Copy store backend - Copyright (C) 1995,96,97,99,2000,01 Free Software Foundation, Inc. + Copyright (C) 1995,96,97,99,2000,01,02 Free Software Foundation, Inc. Written by Miles Bader <miles@gnu.org> This file is part of the GNU Hurd. @@ -36,14 +36,10 @@ copy_read (struct store *store, store_offset_t addr, size_t index, char *data = store->hook + (addr * store->block_size); if (page_aligned (data) && page_aligned (amount)) - { - /* When reading whole pages, we can avoid any real copying. */ - error_t err = vm_read (mach_task_self (), - (vm_address_t) data, amount, - (pointer_t *) buf, len); - *len *= vm_page_size; - return err; - } + /* When reading whole pages, we can avoid any real copying. */ + return vm_read (mach_task_self (), + (vm_address_t) data, amount, + (pointer_t *) buf, len); if (*len < amount) /* Have to allocate memory for the return value. */ 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; |