mirror of
https://github.com/HDFGroup/hdf5.git
synced 2024-11-27 02:10:55 +08:00
[svn-r26002] move checks on reading/writing beyond file eoa outside of the file drivers and into a centralized place in H5FD_read/write.
tested h5committest.
This commit is contained in:
parent
a24e3e5c86
commit
5eee1d7d7e
@ -1230,8 +1230,6 @@ H5FD_core_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, hadd
|
||||
HGOTO_ERROR(H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed")
|
||||
if (REGION_OVERFLOW(addr, size))
|
||||
HGOTO_ERROR(H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed")
|
||||
if((addr + size) > file->eoa)
|
||||
HGOTO_ERROR(H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed")
|
||||
|
||||
/* Read the part which is before the EOF marker */
|
||||
if (addr < file->eof) {
|
||||
@ -1290,8 +1288,6 @@ H5FD_core_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, had
|
||||
/* Check for overflow conditions */
|
||||
if(REGION_OVERFLOW(addr, size))
|
||||
HGOTO_ERROR(H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed")
|
||||
if(addr + size > file->eoa)
|
||||
HGOTO_ERROR(H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed")
|
||||
|
||||
/*
|
||||
* Allocate more memory if necessary, careful of overflow. Also, if the
|
||||
|
@ -897,8 +897,6 @@ H5FD_direct_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, ha
|
||||
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined")
|
||||
if (REGION_OVERFLOW(addr, size))
|
||||
HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow")
|
||||
if((addr + size) > file->eoa)
|
||||
HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow")
|
||||
|
||||
/* If the system doesn't require data to be aligned, read the data in
|
||||
* the same way as sec2 driver.
|
||||
@ -1085,8 +1083,6 @@ H5FD_direct_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, h
|
||||
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined")
|
||||
if (REGION_OVERFLOW(addr, size))
|
||||
HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow")
|
||||
if (addr+size>file->eoa)
|
||||
HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow")
|
||||
|
||||
/* If the system doesn't require data to be aligned, read the data in
|
||||
* the same way as sec2 driver.
|
||||
|
@ -186,6 +186,7 @@ herr_t
|
||||
H5FD_read(H5FD_t *file, const H5P_genplist_t *dxpl, H5FD_mem_t type, haddr_t addr,
|
||||
size_t size, void *buf/*out*/)
|
||||
{
|
||||
haddr_t eoa = HADDR_UNDEF;
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI(FAIL)
|
||||
@ -202,6 +203,12 @@ H5FD_read(H5FD_t *file, const H5P_genplist_t *dxpl, H5FD_mem_t type, haddr_t add
|
||||
HGOTO_DONE(SUCCEED)
|
||||
#endif /* H5_HAVE_PARALLEL */
|
||||
|
||||
if(HADDR_UNDEF == (eoa = (file->cls->get_eoa)(file, type)))
|
||||
HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "driver get_eoa request failed")
|
||||
if((addr + file->base_addr + size) > eoa)
|
||||
HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow, addr = %llu, size=%zu, eoa=%llu",
|
||||
(unsigned long long)(addr+ file->base_addr), size, (unsigned long long)eoa)
|
||||
|
||||
/* Dispatch to driver */
|
||||
if((file->cls->read)(file, type, H5P_PLIST_ID(dxpl), addr + file->base_addr, size, buf) < 0)
|
||||
HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "driver read request failed")
|
||||
@ -228,6 +235,7 @@ herr_t
|
||||
H5FD_write(H5FD_t *file, const H5P_genplist_t *dxpl, H5FD_mem_t type, haddr_t addr,
|
||||
size_t size, const void *buf)
|
||||
{
|
||||
haddr_t eoa = HADDR_UNDEF;
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI(FAIL)
|
||||
@ -244,6 +252,12 @@ H5FD_write(H5FD_t *file, const H5P_genplist_t *dxpl, H5FD_mem_t type, haddr_t ad
|
||||
HGOTO_DONE(SUCCEED)
|
||||
#endif /* H5_HAVE_PARALLEL */
|
||||
|
||||
if(HADDR_UNDEF == (eoa = (file->cls->get_eoa)(file, type)))
|
||||
HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "driver get_eoa request failed")
|
||||
if((addr + file->base_addr + size) > eoa)
|
||||
HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow, addr = %llu, size=%zu, eoa=%llu",
|
||||
(unsigned long long)(addr+ file->base_addr), size, (unsigned long long)eoa)
|
||||
|
||||
/* Dispatch to driver */
|
||||
if((file->cls->write)(file, type, H5P_PLIST_ID(dxpl), addr + file->base_addr, size, buf) < 0)
|
||||
HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "driver write request failed")
|
||||
|
@ -1139,8 +1139,6 @@ H5FD_log_read(H5FD_t *_file, H5FD_mem_t type, hid_t UNUSED dxpl_id, haddr_t addr
|
||||
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined, addr = %llu", (unsigned long long)addr)
|
||||
if(REGION_OVERFLOW(addr, size))
|
||||
HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow, addr = %llu", (unsigned long long)addr)
|
||||
if((addr + size) > file->eoa)
|
||||
HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow, addr = %llu", (unsigned long long)addr)
|
||||
|
||||
/* Log the I/O information about the read */
|
||||
if(file->fa.flags != 0) {
|
||||
@ -1345,8 +1343,6 @@ H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t UNUSED dxpl_id, haddr_t add
|
||||
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined, addr = %llu", (unsigned long long)addr)
|
||||
if(REGION_OVERFLOW(addr, size))
|
||||
HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow, addr = %llu, size = %llu", (unsigned long long)addr, (unsigned long long)size)
|
||||
if((addr + size) > file->eoa)
|
||||
HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow, addr = %llu, size = %llu, eoa = %llu", (unsigned long long)addr, (unsigned long long)size, (unsigned long long)file->eoa)
|
||||
|
||||
/* Log the I/O information about the write */
|
||||
if(file->fa.flags & H5FD_LOG_FILE_WRITE) {
|
||||
|
@ -694,9 +694,6 @@ H5FD_sec2_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id,
|
||||
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined, addr = %llu", (unsigned long long)addr)
|
||||
if(REGION_OVERFLOW(addr, size))
|
||||
HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow, addr = %llu", (unsigned long long)addr)
|
||||
if((addr + size) > file->eoa)
|
||||
HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow, addr = %llu, size=%lu, eoa=%llu",
|
||||
(unsigned long long)addr, size, (unsigned long long)file->eoa)
|
||||
|
||||
/* Seek to the correct location */
|
||||
if(addr != file->pos || OP_READ != file->op) {
|
||||
@ -792,8 +789,6 @@ H5FD_sec2_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id,
|
||||
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined, addr = %llu", (unsigned long long)addr)
|
||||
if(REGION_OVERFLOW(addr, size))
|
||||
HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow, addr = %llu, size = %llu", (unsigned long long)addr, (unsigned long long)size)
|
||||
if((addr + size) > file->eoa)
|
||||
HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow, addr = %llu, size = %llu, eoa = %llu", (unsigned long long)addr, (unsigned long long)size, (unsigned long long)file->eoa)
|
||||
|
||||
/* Seek to the correct location */
|
||||
if(addr != file->pos || OP_WRITE != file->op) {
|
||||
|
@ -799,8 +799,6 @@ H5FD_stdio_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, siz
|
||||
H5Epush_ret (func, H5E_ERR_CLS, H5E_IO, H5E_OVERFLOW, "file address overflowed", -1)
|
||||
if (REGION_OVERFLOW(addr, size))
|
||||
H5Epush_ret (func, H5E_ERR_CLS, H5E_IO, H5E_OVERFLOW, "file address overflowed", -1)
|
||||
if((addr + size) > file->eoa)
|
||||
H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_OVERFLOW, "file address overflowed", -1)
|
||||
|
||||
/* Check easy cases */
|
||||
if (0 == size)
|
||||
@ -906,8 +904,6 @@ H5FD_stdio_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr,
|
||||
H5Epush_ret (func, H5E_ERR_CLS, H5E_IO, H5E_OVERFLOW, "file address overflowed", -1)
|
||||
if (REGION_OVERFLOW(addr, size))
|
||||
H5Epush_ret (func, H5E_ERR_CLS, H5E_IO, H5E_OVERFLOW, "file address overflowed", -1)
|
||||
if (addr+size > file->eoa)
|
||||
H5Epush_ret (func, H5E_ERR_CLS, H5E_IO, H5E_OVERFLOW, "file address overflowed", -1)
|
||||
|
||||
/* Seek to the correct file position. */
|
||||
if ((file->op != H5FD_STDIO_OP_WRITE && file->op != H5FD_STDIO_OP_SEEK) ||
|
||||
|
Loading…
Reference in New Issue
Block a user