summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaymond Lu <songyulu@hdfgroup.org>2002-05-29 21:42:00 (GMT)
committerRaymond Lu <songyulu@hdfgroup.org>2002-05-29 21:42:00 (GMT)
commit1bf7cb7af1c97045d08a659e92256a94c853b87c (patch)
tree9ba57162eabbde8a71a9cf22783f1c371503ab38
parent02350ea835871949c4bee0c534b77b8a3655e794 (diff)
downloadhdf5-1bf7cb7af1c97045d08a659e92256a94c853b87c.zip
hdf5-1bf7cb7af1c97045d08a659e92256a94c853b87c.tar.gz
hdf5-1bf7cb7af1c97045d08a659e92256a94c853b87c.tar.bz2
[svn-r5484]
Purpose: Bug Fixing Description: In H5FD_family_write and H5FD_family_read, size_t is checked against hsize_t for overflow, which fails on IA32 architecture machine supporting large files. Solution: Use temporary variable which won't pass the limit of size_t. Platforms tested: Linux 2.4(platinum) and IRIX64 6.5(modi4)
-rw-r--r--src/H5FDfamily.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/src/H5FDfamily.c b/src/H5FDfamily.c
index 1d4e033..4828d47 100644
--- a/src/H5FDfamily.c
+++ b/src/H5FDfamily.c
@@ -864,9 +864,7 @@ H5FD_family_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, si
int i;
haddr_t sub;
size_t req;
-#ifndef NDEBUG
hsize_t tempreq;
-#endif /* NDEBUG */
H5P_genplist_t *plist; /* Property list pointer */
FUNC_ENTER_NOAPI(H5FD_family_read, FAIL);
@@ -891,13 +889,13 @@ H5FD_family_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, si
sub = addr % file->memb_size;
-#ifndef NDEBUG
+ /* This check is for mainly for IA32 architecture whose size_t's size
+ * is 4 bytes, to prevent overflow when user application is trying to
+ * write files bigger than 4GB. */
tempreq = file->memb_size-sub;
- H5_CHECK_OVERFLOW(tempreq,hsize_t,size_t);
+ if(tempreq > SIZET_MAX)
+ tempreq = SIZET_MAX;
req = MIN(size, (size_t)tempreq);
-#else /* NDEBUG */
- req = MIN(size, (size_t)(file->memb_size-sub));
-#endif /* NDEBUG */
assert(i<file->nmembs);
@@ -942,9 +940,7 @@ H5FD_family_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, s
int i;
haddr_t sub;
size_t req;
-#ifndef NDEBUG
hsize_t tempreq;
-#endif /* NDEBUG */
H5P_genplist_t *plist; /* Property list pointer */
FUNC_ENTER_NOAPI(H5FD_family_write, FAIL);
@@ -969,13 +965,13 @@ H5FD_family_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, s
sub = addr % file->memb_size;
-#ifndef NDEBUG
+ /* This check is for mainly for IA32 architecture whose size_t's size
+ * is 4 bytes, to prevent overflow when user application is trying to
+ * write files bigger than 4GB. */
tempreq = file->memb_size-sub;
- H5_CHECK_OVERFLOW(tempreq,hsize_t,size_t);
+ if(tempreq > SIZET_MAX)
+ tempreq = SIZET_MAX;
req = MIN(size, (size_t)tempreq);
-#else /* NDEBUG */
- req = MIN(size, (size_t)(file->memb_size-sub));
-#endif /* NDEBUG */
assert(i<file->nmembs);