diff options
author | bfriesen <bfriesen> | 2015-06-07 22:47:29 +0000 |
---|---|---|
committer | bfriesen <bfriesen> | 2015-06-07 22:47:29 +0000 |
commit | aeefd89cd3d55d10a77be4327b7813135628bf82 (patch) | |
tree | efbfbe79073d4fddcab4e008514feb1272fc5ba0 | |
parent | 0e3426ab343e3deace07f8fdc27b584f312e2e59 (diff) | |
download | libtiff-aeefd89cd3d55d10a77be4327b7813135628bf82.tar.gz |
(TIFFWriteEncodedTile): Fix Coverity 715976 and 715977 "Division
or modulo by zero".
-rw-r--r-- | ChangeLog | 2 | ||||
-rw-r--r-- | libtiff/tif_write.c | 19 |
2 files changed, 16 insertions, 5 deletions
@@ -2,6 +2,8 @@ * libtiff/tif_write.c (TIFFWriteEncodedStrip): Fix Coverity 715975 "Division or modulo by zero". + (TIFFWriteEncodedTile): Fix Coverity 715976 and 715977 "Division + or modulo by zero". * libtiff/tif_read.c (TIFFStartTile): Fix Coverity 715973 and 715974 "Division or modulo by zero". diff --git a/libtiff/tif_write.c b/libtiff/tif_write.c index fad6ec7f..e4cf6c47 100644 --- a/libtiff/tif_write.c +++ b/libtiff/tif_write.c @@ -1,4 +1,4 @@ -/* $Id: tif_write.c,v 1.39 2015-06-07 22:41:07 bfriesen Exp $ */ +/* $Id: tif_write.c,v 1.40 2015-06-07 22:47:29 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -358,6 +358,7 @@ TIFFWriteEncodedTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc) static const char module[] = "TIFFWriteEncodedTile"; TIFFDirectory *td; uint16 sample; + uint32 howmany32; if (!WRITECHECKTILES(tif, module)) return ((tmsize_t)(-1)); @@ -403,10 +404,18 @@ TIFFWriteEncodedTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc) * Compute tiles per row & per column to compute * current row and column */ - tif->tif_row = (tile % TIFFhowmany_32(td->td_imagelength, td->td_tilelength)) - * td->td_tilelength; - tif->tif_col = (tile % TIFFhowmany_32(td->td_imagewidth, td->td_tilewidth)) - * td->td_tilewidth; + howmany32=TIFFhowmany_32(td->td_imagelength, td->td_tilelength); + if (howmany32 == 0) { + TIFFErrorExt(tif->tif_clientdata,module,"Zero tiles"); + return ((tmsize_t)(-1)); + } + tif->tif_row = (tile % howmany32) * td->td_tilelength; + howmany32=TIFFhowmany_32(td->td_imagewidth, td->td_tilewidth); + if (howmany32 == 0) { + TIFFErrorExt(tif->tif_clientdata,module,"Zero tiles"); + return ((tmsize_t)(-1)); + } + tif->tif_col = (tile % howmany32) * td->td_tilewidth; if ((tif->tif_flags & TIFF_CODERSETUP) == 0) { if (!(*tif->tif_setupencode)(tif)) |