From c3e3173779b3539bd7d14bcf2a500f394f75e154 Mon Sep 17 00:00:00 2001 From: Bob Friesenhahn Date: Fri, 6 Jul 2012 23:24:46 +0000 Subject: [PATCH] Used signed overflow checks rather than unsigned integer overflow checks since C language does not define signed overflow behavior --- libtiff/tif_dirread.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/libtiff/tif_dirread.c b/libtiff/tif_dirread.c index c242d8fa..2e1e379e 100644 --- a/libtiff/tif_dirread.c +++ b/libtiff/tif_dirread.c @@ -1,4 +1,4 @@ -/* $Id: tif_dirread.c,v 1.174 2012-02-01 02:24:47 fwarmerdam Exp $ */ +/* $Id: tif_dirread.c,v 1.175 2012-07-06 23:24:46 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -3313,10 +3313,15 @@ TIFFReadDirEntryData(TIFF* tif, uint64 offset, tmsize_t size, void* dest) if (!ReadOK(tif,dest,size)) return(TIFFReadDirEntryErrIo); } else { - tmsize_t ma,mb; - ma=(tmsize_t)offset; + size_t ma,mb; + ma=(size_t)offset; mb=ma+size; - if (((uint64)ma!=offset)||(mbtif->tif_size)) + if (((uint64)ma!=offset) + || (mb < ma) + || (mb - ma != (size_t) size) + || (mb < (size_t)size) + || (mb > (size_t)tif->tif_size) + ) return(TIFFReadDirEntryErrIo); _TIFFmemcpy(dest,tif->tif_base+ma,size); }