diff options
author | Erik Schnetter <schnetter@cct.lsu.edu> | 2008-02-19 05:22:00 +0000 |
---|---|---|
committer | Erik Schnetter <schnetter@cct.lsu.edu> | 2008-02-19 05:22:00 +0000 |
commit | 01bdc9684d6287aad70c7b9364d2e76dd43429de (patch) | |
tree | 31fda8567ae41a6f8b215a5c447abf47d4f22412 /Carpet/CarpetIOHDF5/src/Output.cc | |
parent | 3b9d6da08ee120351ca827e0d3bf48970d4591e1 (diff) |
CarpetIOHDF5: Make code safer
Change sprintf to snprintf. Add assert statements.
darcs-hash:20080219052249-dae7b-abbdbb9df6c099cdd62ebaac135b654062659619.gz
Diffstat (limited to 'Carpet/CarpetIOHDF5/src/Output.cc')
-rw-r--r-- | Carpet/CarpetIOHDF5/src/Output.cc | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Carpet/CarpetIOHDF5/src/Output.cc b/Carpet/CarpetIOHDF5/src/Output.cc index c534e3cf1..8bc68faa0 100644 --- a/Carpet/CarpetIOHDF5/src/Output.cc +++ b/Carpet/CarpetIOHDF5/src/Output.cc @@ -94,6 +94,7 @@ int WriteVarUnchunked (const cGH* const cctkGH, hsize_t shape[dim]; hsize_t num_elems = 1; for (int d = 0; d < group.dim; ++d) { + assert (group.dim-1-d>=0 and group.dim-1-d<dim); shape[group.dim-1-d] = (bbox->shape() / bbox->stride())[d]; num_elems *= shape[group.dim-1-d]; } @@ -213,6 +214,7 @@ int WriteVarUnchunked (const cGH* const cctkGH, hsize_t overlaporigin[dim]; #endif for (int d = 0; d < group.dim; ++d) { + assert (group.dim-1-d>=0 and group.dim-1-d<dim); overlaporigin[group.dim-1-d] = ((overlap.lower() - bbox->lower()) / overlap.stride())[d]; overlapshape[group.dim-1-d] = @@ -326,6 +328,7 @@ int WriteVarChunkedSequential (const cGH* const cctkGH, hsize_t shape[dim]; hsize_t num_elems = 1; for (int d = 0; d < group.dim; ++d) { + assert (group.dim-1-d>=0 and group.dim-1-d<dim); shape[group.dim-1-d] = (bbox.shape() / bbox.stride())[d]; num_elems *= shape[group.dim-1-d]; } @@ -393,6 +396,7 @@ int WriteVarChunkedSequential (const cGH* const cctkGH, hsize_t shape[dim]; hssize_t origin[dim]; for (int d = 0; d < group.dim; ++d) { + assert (group.dim-1-d>=0 and group.dim-1-d<dim); origin[group.dim-1-d] = (bbox.lower() / bbox.stride())[d]; shape[group.dim-1-d] = (bbox.shape() / bbox.stride())[d]; } @@ -545,6 +549,7 @@ int WriteVarChunkedParallel (const cGH* const cctkGH, hsize_t shape[dim]; hssize_t origin[dim]; for (int d = 0; d < group.dim; ++d) { + assert (group.dim-1-d>=0 and group.dim-1-d<dim); origin[group.dim-1-d] = (bbox.lower() / bbox.stride())[d]; shape[group.dim-1-d] = (bbox.shape() / bbox.stride())[d]; } @@ -591,6 +596,7 @@ static int AddAttributes (const cGH *const cctkGH, const char *fullname, const ioRequest* request, const ibbox& bbox, hid_t dataset) { + assert (vdim>=0 and vdim<=dim); int error_count = 0; // Legacy arguments |