From 007668c16ae2f550446c14ae27cff569da6f38b7 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Mon, 30 Jul 2001 13:57:04 -0500 Subject: [svn-r4276] Purpose: Bug Fix Description: In certain circumstances, raw data was inadvertantly attempted to be read from the metadata cache. This was caught with an assertion failure (i.e. core dump) in the development branch or an eventual sequence of errors in the release branch. Solution: Corrected off-by-one error in metadata caching code. Platforms tested: FreeBSD 4.3 (hawkwind) --- src/H5FD.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/H5FD.c b/src/H5FD.c index 1b04a01..f8538ae 100644 --- a/src/H5FD.c +++ b/src/H5FD.c @@ -2029,9 +2029,9 @@ H5FD_read(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t siz /* Check if this information is in the metadata accumulator */ if((file->feature_flags&H5FD_FEAT_ACCUMULATE_METADATA) && - ((addr>=file->accum_loc && addr <=(file->accum_loc+file->accum_size)) - || ((addr+size)>=file->accum_loc && (addr+size)<=(file->accum_loc+file->accum_size)) - || (addraccum_loc && (addr+size)>(file->accum_loc+file->accum_size)))) { + ((addr>=file->accum_loc && addr <(file->accum_loc+file->accum_size)) + || ((addr+size)>file->accum_loc && (addr+size)<=(file->accum_loc+file->accum_size)) + || (addraccum_loc && (addr+size)>file->accum_loc))) { unsigned char *read_buf=(unsigned char *)buf; /* Pointer to the buffer being read in */ size_t amount_read; /* Amount to read at a time */ @@ -2055,7 +2055,7 @@ H5FD_read(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t siz size-=amount_read; } /* end if */ - /* Read the part overlapping the metadata accumulator */ + /* Copy the part overlapping the metadata accumulator */ if(size>0 && (addr>=file->accum_loc && addr<(file->accum_loc+file->accum_size))) { /* Set the offset to "read" from */ read_off=addr-file->accum_loc; @@ -2192,9 +2192,9 @@ H5FD_write(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t si /* Check if there is already metadata in the accumulator */ if(file->accum_size>0) { /* Check if the piece of metadata being written adjoins or is inside the metadata accumulator */ - if((addr>=file->accum_loc && addr <=(file->accum_loc+file->accum_size)) - || ((addr+size)>=file->accum_loc && (addr+size)<=(file->accum_loc+file->accum_size)) - || (addraccum_loc && (addr+size)>(file->accum_loc+file->accum_size))) { + if((addr>=file->accum_loc && addr <(file->accum_loc+file->accum_size)) + || ((addr+size)>file->accum_loc && (addr+size)<=(file->accum_loc+file->accum_size)) + || (addraccum_loc && (addr+size)>file->accum_loc)) { /* Check if the new metadata adjoins the beginning of the current accumulator */ if((addr+size)==file->accum_loc) { @@ -2284,7 +2284,7 @@ H5FD_write(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t si /* Check if the new metadata overlaps the end of the current accumulator */ else if(addr>=file->accum_loc && (addr+size)>(file->accum_loc+file->accum_size)) { /* Calculate the new accumulator size, based on the amount of overlap */ - new_size=file->accum_size+((addr+size)-(file->accum_loc+file->accum_size)); + new_size=(addr-file->accum_loc)+size; /* Check if we need more buffer space */ if(new_size>file->accum_buf_size) { -- cgit v0.12