summaryrefslogtreecommitdiffstats
path: root/hl/tools/gif2h5/hdf2gif.c
diff options
context:
space:
mode:
authorAlbert Cheng <acheng@hdfgroup.org>2015-03-30 05:28:13 (GMT)
committerAlbert Cheng <acheng@hdfgroup.org>2015-03-30 05:28:13 (GMT)
commit56fe37c8e67b9a3331564f35f5ebe008b6fb8a0d (patch)
treeb1e0831879ffd166df40d698f5641268efc44d84 /hl/tools/gif2h5/hdf2gif.c
parentf617eeb78fbc2df5baacc9b0af9a08920a3538d8 (diff)
downloadhdf5-56fe37c8e67b9a3331564f35f5ebe008b6fb8a0d.zip
hdf5-56fe37c8e67b9a3331564f35f5ebe008b6fb8a0d.tar.gz
hdf5-56fe37c8e67b9a3331564f35f5ebe008b6fb8a0d.tar.bz2
[svn-r26646] Bug fix: HDFFV-8957 h52gif crashes when run against one of our own examples.
Description: h52gif crashed when it was asked to convert a 24bitimage. Upon viewing the code, it did not prepare to handle images other than 2 dimensions. It has no concept of multiple planes images. Further examinations showed past attempts to fix it ended up removed some abilities (-p or multiple planes, animation, ...) have been removed but documentation was not updated. Even its online help message still shows -p is an option. Solution: added protection code to flag errors if input request is not an 8bit image within size limits. (I don't have enough knowledge of the GIF format to fix this tool. All I did was plugging known bug from crashing the program.) Tested: h5committest.
Diffstat (limited to 'hl/tools/gif2h5/hdf2gif.c')
-rw-r--r--hl/tools/gif2h5/hdf2gif.c13
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 )