summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/H5D.c36
-rw-r--r--src/H5Distore.c5
-rw-r--r--src/H5FD.c6
-rw-r--r--src/H5Fistore.c5
-rw-r--r--src/H5Sall.c3
-rw-r--r--src/H5Shyper.c20
-rw-r--r--src/H5Spoint.c3
-rw-r--r--src/H5Sselect.c18
-rw-r--r--src/H5Tconv.c13
9 files changed, 68 insertions, 41 deletions
diff --git a/src/H5D.c b/src/H5D.c
index 1037f4b..8b312df 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -1926,21 +1926,27 @@ H5D_create(H5G_entry_t *loc, const char *name, const H5T_t *type,
break;
case H5D_COMPACT:
- /*
- * Compact dataset is stored in dataset object header message of
- * layout.
- */
- new_dset->layout.size = H5S_get_simple_extent_npoints(space) *
- H5T_get_size(type);
- /* Verify data size is smaller than maximum header message size
- * (64KB) minus other layout message fields.
- */
- comp_data_size=H5O_MAX_SIZE-H5O_layout_meta_size(file, &(new_dset->layout));
- if(new_dset->layout.size > comp_data_size)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "compact dataset size is bigger than header message maximum size");
- if ((ndims=H5S_get_simple_extent_dims(space, new_dset->layout.dim, max_dim))<0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize dimension size of compact dataset storage");
- /* remember to check if size is small enough to fit header message */
+ {
+ hssize_t tmp_size; /* Temporary holder for raw data size */
+
+ /*
+ * Compact dataset is stored in dataset object header message of
+ * layout.
+ */
+ tmp_size = H5S_get_simple_extent_npoints(space) *
+ H5T_get_size(type);
+ H5_ASSIGN_OVERFLOW(new_dset->layout.size,tmp_size,hssize_t,size_t);
+ /* Verify data size is smaller than maximum header message size
+ * (64KB) minus other layout message fields.
+ */
+ comp_data_size=H5O_MAX_SIZE-H5O_layout_meta_size(file, &(new_dset->layout));
+ if(new_dset->layout.size > comp_data_size)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "compact dataset size is bigger than header message maximum size");
+ if ((ndims=H5S_get_simple_extent_dims(space, new_dset->layout.dim, max_dim))<0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize dimension size of compact dataset storage");
+ /* remember to check if size is small enough to fit header message */
+
+ }
break;
diff --git a/src/H5Distore.c b/src/H5Distore.c
index 5278554..aa88704 100644
--- a/src/H5Distore.c
+++ b/src/H5Distore.c
@@ -2431,7 +2431,7 @@ H5F_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
/* Check if there are filters which need to be applied to the chunk */
if (pline.nfilters>0) {
unsigned filter_mask=0;
- size_t buf_size=chunk_size;
+ size_t buf_size=(size_t)chunk_size;
size_t nbytes=(size_t)chunk_size;
/* Push the chunk through the filters */
@@ -2476,7 +2476,8 @@ H5F_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
udata.mesg = *layout;
udata.key.filter_mask = 0;
udata.addr = HADDR_UNDEF;
- udata.key.nbytes = chunk_size;
+ H5_CHECK_OVERFLOW(chunk_size,hsize_t,size_t);
+ udata.key.nbytes = (size_t)chunk_size;
for (u=0; u<layout->ndims; u++)
udata.key.offset[u] = chunk_offset[u];
diff --git a/src/H5FD.c b/src/H5FD.c
index 3ba0739..7c2c701 100644
--- a/src/H5FD.c
+++ b/src/H5FD.c
@@ -1786,7 +1786,7 @@ H5FD_free(H5FD_t *file, H5FD_mem_t type, haddr_t addr, hsize_t size)
size_t new_accum_size; /* Size of new accumulator buffer */
/* Calculate the size of the overlap with the accumulator, etc. */
- overlap_size=(addr+size)-file->accum_loc;
+ H5_ASSIGN_OVERFLOW(overlap_size,(addr+size)-file->accum_loc,haddr_t,size_t);
new_accum_size=file->accum_size-overlap_size;
/* Move the accumulator buffer information to eliminate the freed block */
@@ -1800,7 +1800,7 @@ H5FD_free(H5FD_t *file, H5FD_mem_t type, haddr_t addr, hsize_t size)
/* Block to free must start within the accumulator */
else {
/* Calculate the size of the overlap with the accumulator */
- overlap_size=(file->accum_loc+file->accum_size)-addr;
+ H5_ASSIGN_OVERFLOW(overlap_size,(file->accum_loc+file->accum_size)-addr,haddr_t,size_t);
/* Block to free is in the middle of the accumulator */
if(H5F_addr_lt(addr,file->accum_loc+file->accum_size)) {
@@ -1809,7 +1809,7 @@ H5FD_free(H5FD_t *file, H5FD_mem_t type, haddr_t addr, hsize_t size)
/* Calculate the address & size of the tail to write */
tail_addr=addr+size;
- tail_size=(file->accum_loc+file->accum_size)-tail_addr;
+ H5_ASSIGN_OVERFLOW(tail_size,(file->accum_loc+file->accum_size)-tail_addr,haddr_t,size_t);
/* Write out the part of the accumulator after the block to free */
if (H5FD_write(file, H5FD_MEM_DEFAULT, H5P_DATASET_XFER_DEFAULT, tail_addr, tail_size, file->meta_accum+(tail_addr-file->accum_loc))<0)
diff --git a/src/H5Fistore.c b/src/H5Fistore.c
index 5278554..aa88704 100644
--- a/src/H5Fistore.c
+++ b/src/H5Fistore.c
@@ -2431,7 +2431,7 @@ H5F_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
/* Check if there are filters which need to be applied to the chunk */
if (pline.nfilters>0) {
unsigned filter_mask=0;
- size_t buf_size=chunk_size;
+ size_t buf_size=(size_t)chunk_size;
size_t nbytes=(size_t)chunk_size;
/* Push the chunk through the filters */
@@ -2476,7 +2476,8 @@ H5F_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
udata.mesg = *layout;
udata.key.filter_mask = 0;
udata.addr = HADDR_UNDEF;
- udata.key.nbytes = chunk_size;
+ H5_CHECK_OVERFLOW(chunk_size,hsize_t,size_t);
+ udata.key.nbytes = (size_t)chunk_size;
for (u=0; u<layout->ndims; u++)
udata.key.offset[u] = chunk_offset[u];
diff --git a/src/H5Sall.c b/src/H5Sall.c
index bc7a162..a8e5f40 100644
--- a/src/H5Sall.c
+++ b/src/H5Sall.c
@@ -646,7 +646,8 @@ H5S_all_get_seq_list(const H5S_t UNUSED *space, unsigned UNUSED flags, H5S_sel_i
/* Compute the offset in the dataset */
off[0]=iter->all.offset*elem_size;
- len[0]=MIN(maxbytes,bytes_left);
+ H5_CHECK_OVERFLOW(bytes_left,hsize_t,size_t);
+ len[0]=MIN(maxbytes,(size_t)bytes_left);
/* Should only need one sequence for 'all' selections */
*nseq=1;
diff --git a/src/H5Shyper.c b/src/H5Shyper.c
index 25e52c8..4ed0b2d 100644
--- a/src/H5Shyper.c
+++ b/src/H5Shyper.c
@@ -5099,7 +5099,8 @@ H5S_hyper_get_seq_list_gen(const H5S_t *space,H5S_sel_iter_t *iter,
ispan=iter->hyp.span;
/* Set the amount of elements to perform I/O on, etc. */
- start_io_bytes_left=io_bytes_left=MIN(maxbytes,(iter->hyp.elmt_left*elem_size));
+ H5_CHECK_OVERFLOW( (iter->hyp.elmt_left*elem_size) ,hsize_t,size_t);
+ start_io_bytes_left=io_bytes_left=MIN(maxbytes,(size_t)(iter->hyp.elmt_left*elem_size));
nelem=io_bytes_left/elem_size;
/* Compute the cumulative size of dataspace dimensions */
@@ -5563,10 +5564,11 @@ H5S_hyper_get_seq_list_opt(const H5S_t *space,H5S_sel_iter_t *iter,
size_t leftover; /* The number of elements left over from the last sequence */
/* Calculate the number of elements left in the sequence */
+ H5_CHECK_OVERFLOW( tdiminfo[fast_dim].block-(iter->hyp.off[fast_dim]-tdiminfo[fast_dim].start) ,hsize_t,size_t);
if(tdiminfo[fast_dim].stride==1)
- leftover=tdiminfo[fast_dim].block-(iter->hyp.off[fast_dim]-tdiminfo[fast_dim].start);
+ leftover=(size_t)(tdiminfo[fast_dim].block-(iter->hyp.off[fast_dim]-tdiminfo[fast_dim].start));
else
- leftover=tdiminfo[fast_dim].block-((iter->hyp.off[fast_dim]-tdiminfo[fast_dim].start)%tdiminfo[fast_dim].stride);
+ leftover=(size_t)(tdiminfo[fast_dim].block-((iter->hyp.off[fast_dim]-tdiminfo[fast_dim].start)%tdiminfo[fast_dim].stride));
/* Make certain that we don't write too many */
actual_elem=MIN(leftover,io_left);
@@ -5651,7 +5653,8 @@ H5S_hyper_get_seq_list_opt(const H5S_t *space,H5S_sel_iter_t *iter,
fast_dim_offset=fast_dim_start+sel_off[fast_dim];
/* Compute the number of blocks which would fit into the buffer */
- tot_blk_count=io_left/fast_dim_block;
+ H5_CHECK_OVERFLOW(io_left/fast_dim_block,hsize_t,size_t);
+ tot_blk_count=(size_t)(io_left/fast_dim_block);
/* Don't go over the maximum number of sequences allowed */
tot_blk_count=MIN(tot_blk_count,(maxseq-curr_seq));
@@ -5748,7 +5751,8 @@ H5S_hyper_get_seq_list_opt(const H5S_t *space,H5S_sel_iter_t *iter,
} /* end if */
/* Compute the number of entire rows to read in */
- curr_rows=total_rows=tot_blk_count/tdiminfo[fast_dim].count;
+ H5_CHECK_OVERFLOW( tot_blk_count/tdiminfo[fast_dim].count ,hsize_t,size_t);
+ curr_rows=total_rows=(size_t)(tot_blk_count/tdiminfo[fast_dim].count);
/* Reset copy of number of blocks in fastest dimension */
H5_ASSIGN_OVERFLOW(fast_dim_count,tdiminfo[fast_dim].count,hsize_t,size_t);
@@ -5910,10 +5914,12 @@ H5S_hyper_get_seq_list_opt(const H5S_t *space,H5S_sel_iter_t *iter,
/* Adjust the number of blocks & elements left to transfer */
/* Decrement number of elements left */
- io_left -= actual_elem*(total_rows*tdiminfo[fast_dim].count);
+ H5_CHECK_OVERFLOW( actual_elem*(total_rows*tdiminfo[fast_dim].count) ,hsize_t,size_t);
+ io_left -= (size_t)(actual_elem*(total_rows*tdiminfo[fast_dim].count));
/* Decrement number of blocks left */
- tot_blk_count -= (total_rows*tdiminfo[fast_dim].count);
+ H5_CHECK_OVERFLOW( (total_rows*tdiminfo[fast_dim].count) ,hsize_t,size_t);
+ tot_blk_count -= (size_t)(total_rows*tdiminfo[fast_dim].count);
/* Read in partial row of blocks */
if(io_left>0 && curr_seq<maxseq) {
diff --git a/src/H5Spoint.c b/src/H5Spoint.c
index 0a59d67..8ec2ae6 100644
--- a/src/H5Spoint.c
+++ b/src/H5Spoint.c
@@ -1242,7 +1242,8 @@ H5S_point_get_seq_list(const H5S_t *space, unsigned flags, H5S_sel_iter_t *iter,
*nseq=curr_seq;
/* Set the number of bytes used */
- *nbytes=(start_bytes_left-bytes_left);
+ H5_CHECK_OVERFLOW( (start_bytes_left-bytes_left) ,hsize_t,size_t);
+ *nbytes=(size_t)(start_bytes_left-bytes_left);
done:
FUNC_LEAVE_NOAPI(ret_value);
diff --git a/src/H5Sselect.c b/src/H5Sselect.c
index 77068a0..8d808c5 100644
--- a/src/H5Sselect.c
+++ b/src/H5Sselect.c
@@ -1216,7 +1216,14 @@ H5S_select_read(H5F_t *f, const H5O_layout_t *layout, H5P_genplist_t *dc_plist,
mem_iter_init=1; /* Memory selection iteration info has been initialized */
/* Get number of bytes in selection */
- maxbytes=(*file_space->select.get_npoints)(file_space)*elmt_size;
+#ifndef NDEBUG
+ {
+ hsize_t tmp_maxbytes=(*file_space->select.get_npoints)(file_space)*elmt_size;
+ H5_ASSIGN_OVERFLOW(maxbytes,tmp_maxbytes,hsize_t,size_t);
+ }
+#else /* NDEBUG */
+ maxbytes=(size_t)((*file_space->select.get_npoints)(file_space)*elmt_size);
+#endif /* NDEBUG */
/* Initialize sequence counts */
curr_mem_seq=curr_file_seq=0;
@@ -1443,7 +1450,14 @@ H5S_select_write(H5F_t *f, H5O_layout_t *layout, H5P_genplist_t *dc_plist,
mem_iter_init=1; /* Memory selection iteration info has been initialized */
/* Get number of bytes in selection */
- maxbytes=(*file_space->select.get_npoints)(file_space)*elmt_size;
+#ifndef NDEBUG
+ {
+ hsize_t tmp_maxbytes=(*file_space->select.get_npoints)(file_space)*elmt_size;
+ H5_ASSIGN_OVERFLOW(maxbytes,tmp_maxbytes,hsize_t,size_t);
+ }
+#else /* NDEBUG */
+ maxbytes=(size_t)((*file_space->select.get_npoints)(file_space)*elmt_size);
+#endif /* NDEBUG */
/* Initialize sequence counts */
curr_mem_seq=curr_file_seq=0;
diff --git a/src/H5Tconv.c b/src/H5Tconv.c
index a1df8e8..affa795 100644
--- a/src/H5Tconv.c
+++ b/src/H5Tconv.c
@@ -2272,16 +2272,13 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts,
uint8_t *tmp=bg_ptr;
UINT32DECODE(tmp, bg_seq_len);
if(bg_seq_len>0) {
- if(tmp_buf_size<bg_seq_len*MAX(src_base_size,
- dst_base_size)) {
- tmp_buf_size=bg_seq_len*MAX(src_base_size,
- dst_base_size);
- if((tmp_buf=H5FL_BLK_REALLOC(vlen_seq,tmp_buf,
- tmp_buf_size))==NULL)
+ H5_CHECK_OVERFLOW( bg_seq_len*MAX(src_base_size,dst_base_size) ,hsize_t,size_t);
+ if(tmp_buf_size<(size_t)(bg_seq_len*MAX(src_base_size, dst_base_size))) {
+ tmp_buf_size=bg_seq_len*MAX(src_base_size, dst_base_size);
+ if((tmp_buf=H5FL_BLK_REALLOC(vlen_seq,tmp_buf, tmp_buf_size))==NULL)
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion");
}
- H5F_addr_decode(dst->u.vlen.f, (const uint8_t **)&tmp,
- &(bg_hobjid.addr));
+ H5F_addr_decode(dst->u.vlen.f, (const uint8_t **)&tmp, &(bg_hobjid.addr));
INT32DECODE(tmp, bg_hobjid.idx);
if(H5HG_read(dst->u.vlen.f,&bg_hobjid,tmp_buf)==NULL)
HGOTO_ERROR (H5E_DATATYPE, H5E_READERROR, FAIL, "can't read VL sequence into background buffer");