diff options
author | Albert Cheng <acheng@hdfgroup.org> | 2015-03-31 20:44:43 (GMT) |
---|---|---|
committer | Albert Cheng <acheng@hdfgroup.org> | 2015-03-31 20:44:43 (GMT) |
commit | fa62ddeba57319c9b691ecd669d317fe7c660980 (patch) | |
tree | 2be2a8eed005c55df489d86f80ba816a071816e3 /hl/tools/gif2h5/hdf2gif.c | |
parent | 756e9611816ffe630f03b5c86323b612921d8b9c (diff) | |
download | hdf5-fa62ddeba57319c9b691ecd669d317fe7c660980.zip hdf5-fa62ddeba57319c9b691ecd669d317fe7c660980.tar.gz hdf5-fa62ddeba57319c9b691ecd669d317fe7c660980.tar.bz2 |
[svn-r26681] Merge r26677 from trunk.
HDFFV-8957: h52gif crashes when run against one of our own examples
The tool claimed it could handle 24bit images but there was no code to handle it.
(or might be there were but was removed by previous revisions.)
Also discovered that it does not accept multiple images nor -p for palette
as its user document and online help message indicated.
Solution:
Added code to verify dimension sizes are within 8 bit raster images limit and
added tests to verify the tools correctness.
Need to update user document tool.
Tested: h5committested.
Diffstat (limited to 'hl/tools/gif2h5/hdf2gif.c')
-rw-r--r-- | hl/tools/gif2h5/hdf2gif.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/hl/tools/gif2h5/hdf2gif.c b/hl/tools/gif2h5/hdf2gif.c index fe79975..5c342ba 100644 --- a/hl/tools/gif2h5/hdf2gif.c +++ b/hl/tools/gif2h5/hdf2gif.c @@ -20,6 +20,8 @@ #include "h5tools.h" #include "h5tools_utils.h" +#define IMAGE_WIDTH_MAX 65535 /* unsigned 16bits integer */ +#define IMAGE_HEIGHT_MAX 65535 /* unsigned 16bits integer */ int EndianOrder; @@ -147,6 +149,17 @@ int main(int argc , char **argv) if ( H5IMget_image_info( fid, image_name, &width, &height, &planes, interlace, &npals ) < 0 ) goto out; + if (width > IMAGE_WIDTH_MAX || height > IMAGE_HEIGHT_MAX){ + fprintf(stderr, "HDF5 image is too large. Limit is %d by %d.\n", IMAGE_WIDTH_MAX, IMAGE_HEIGHT_MAX); + goto out; + } + + /* tool can handle single plane images only. */ + if (planes > 1){ + fprintf(stderr, "Cannot handle multiple planes image\n"); + goto out; + } + Image = (BYTE*) malloc( (size_t) width * (size_t) height ); if ( H5IMread_image( fid, image_name, Image ) < 0 ) |