diff options
author | Even Rouault <even.rouault@spatialys.com> | 2019-08-20 18:09:46 +0200 |
---|---|---|
committer | Even Rouault <even.rouault@spatialys.com> | 2019-08-20 18:09:46 +0200 |
commit | 324aa65c0df9fc74349b63b3e35a3888596cd468 (patch) | |
tree | 1dec0669173a051f7c32629095d7e53700295e98 | |
parent | dd50fedc2f660f73615d1aca043ac66de6af4117 (diff) | |
download | libtiff-git-324aa65c0df9fc74349b63b3e35a3888596cd468.tar.gz |
EstimateStripByteCounts(): avoid harmless unsigned integer overflow
-rw-r--r-- | libtiff/tif_dirread.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/libtiff/tif_dirread.c b/libtiff/tif_dirread.c index 02642057..605b5b95 100644 --- a/libtiff/tif_dirread.c +++ b/libtiff/tif_dirread.c @@ -4578,8 +4578,14 @@ EstimateStripByteCounts(TIFF* tif, TIFFDirEntry* dir, uint16 dircount) * of data in the strip and trim this number back accordingly. */ strip--; - if (td->td_stripoffset_p[strip]+td->td_stripbytecount_p[strip] > filesize) - td->td_stripbytecount_p[strip] = filesize - td->td_stripoffset_p[strip]; + if (td->td_stripoffset_p[strip]+td->td_stripbytecount_p[strip] > filesize) { + if( td->td_stripoffset_p[strip] >= filesize ) { + /* Not sure what we should in that case... */ + td->td_stripbytecount_p[strip] = 0; + } else { + td->td_stripbytecount_p[strip] = filesize - td->td_stripoffset_p[strip]; + } + } } else if (isTiled(tif)) { uint64 bytespertile = TIFFTileSize64(tif); |