summaryrefslogtreecommitdiffstats
path: root/src/H5FDint.c
diff options
context:
space:
mode:
authorMohamad Chaarawi <chaarawi@hdfgroup.org>2015-01-22 17:15:21 (GMT)
committerMohamad Chaarawi <chaarawi@hdfgroup.org>2015-01-22 17:15:21 (GMT)
commit5eee1d7d7e352d90e0350f235b8066550a51f19b (patch)
tree5985bea338d90789ea6a3992b7c7171b7e4890b1 /src/H5FDint.c
parenta24e3e5c8669fd205b75d264ca44e23fc1bfc651 (diff)
downloadhdf5-5eee1d7d7e352d90e0350f235b8066550a51f19b.zip
hdf5-5eee1d7d7e352d90e0350f235b8066550a51f19b.tar.gz
hdf5-5eee1d7d7e352d90e0350f235b8066550a51f19b.tar.bz2
[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.
Diffstat (limited to 'src/H5FDint.c')
-rw-r--r--src/H5FDint.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/H5FDint.c b/src/H5FDint.c
index 4f3c234..a71889a 100644
--- a/src/H5FDint.c
+++ b/src/H5FDint.c
@@ -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")