diff --git a/ChangeLog b/ChangeLog index 5aca13d7..8e57b089 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,7 @@ for 64-bit systems. Add some header validations. Should fix many Coverity issues. (main): Fix Coverity 1301206: "Integer handling issues (BAD_SHIFT)". + (main): Quiet Coverity 1024223 "Untrusted value as argument". * tools/tiffmedian.c (GetInputLine): Fix Coverity 1024795 "Nesting level does not match indentation". diff --git a/tools/ras2tiff.c b/tools/ras2tiff.c index c092705b..56138767 100644 --- a/tools/ras2tiff.c +++ b/tools/ras2tiff.c @@ -1,4 +1,4 @@ -/* $Id: ras2tiff.c,v 1.20 2015-05-28 03:52:00 bfriesen Exp $ */ +/* $Id: ras2tiff.c,v 1.21 2015-05-28 04:07:31 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -30,6 +30,7 @@ #include #include #include +#include #ifdef HAVE_UNISTD_H # include @@ -122,13 +123,13 @@ main(int argc, char* argv[]) fclose(in); return (-3); } - if ((h.ras_width <= 0) || - (h.ras_height <= 0) || - (h.ras_depth <= 0) || - (h.ras_length <= 0) || + if ((h.ras_width <= 0) || (h.ras_width >= INT_MAX) || + (h.ras_height <= 0) || (h.ras_height >= INT_MAX) || + (h.ras_depth <= 0) || (h.ras_depth >= INT_MAX) || + (h.ras_length <= 0) || (h.ras_length >= INT_MAX) || (h.ras_type <= 0) || (h.ras_maptype <= 0) || - (h.ras_maplength <= 0)) { + (h.ras_maplength <= 0) || (h.ras_maplength >= INT_MAX)) { fprintf(stderr, "%s: Improper image header.\n", argv[optind]); fclose(in); return (-2);