From 807622ba0f32ff0f47762e4b9977aba03b912ee3 Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Mon, 4 Aug 2003 22:00:24 +0000 Subject: 2003-07-21 Ognyan Kulev * rdwr.c (store_write): Return EINVAL when LEN is not aligned to STORE->block_size, instead of raising assertion failure. (store_read): Likewise. --- libstore/ChangeLog | 6 ++++++ libstore/rdwr.c | 12 +++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/libstore/ChangeLog b/libstore/ChangeLog index af21782c..0be23c87 100644 --- a/libstore/ChangeLog +++ b/libstore/ChangeLog @@ -1,3 +1,9 @@ +2003-07-21 Ognyan Kulev + + * rdwr.c (store_write): Return EINVAL when LEN is not aligned to + STORE->block_size, instead of raising assertion failure. + (store_read): Likewise. + 2003-08-04 Roland McGrath * typed.c (store_find_class): Use dlopen/dlclose on the names found by diff --git a/libstore/rdwr.c b/libstore/rdwr.c index 354b193a..9737c515 100644 --- a/libstore/rdwr.c +++ b/libstore/rdwr.c @@ -1,6 +1,6 @@ /* Store I/O - Copyright (C) 1995,96,97,98,99,2001,02 Free Software Foundation, Inc. + Copyright (C) 1995-1999,2001,2002,2003 Free Software Foundation, Inc. Written by Miles Bader This file is part of the GNU Hurd. @@ -89,8 +89,6 @@ store_next_run (struct store *store, struct store_run *runs_end, return 1; } -#include - /* Write LEN bytes from BUF to STORE at ADDR. Returns the amount written in AMOUNT. ADDR is in BLOCKS (as defined by STORE->block_size). */ error_t @@ -110,8 +108,8 @@ store_write (struct store *store, if ((addr << block_shift) + len > store->size) return EIO; - if (store->block_size != 0) - assert ((len & (store->block_size - 1)) == 0); + if (store->block_size != 0 && (len & (store->block_size - 1)) != 0) + return EINVAL; addr = store_find_first_run (store, addr, &run, &runs_end, &base, &index); if (addr < 0) @@ -190,8 +188,8 @@ store_read (struct store *store, 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); + if (store->block_size != 0 && (amount & (store->block_size - 1)) != 0) + return EINVAL; if ((amount >> block_shift) <= run->length - addr) /* The first run has it all... */ -- cgit v1.2.3