From f0770083a2c09f7e46d0d37250fe9898bddc5b84 Mon Sep 17 00:00:00 2001 From: Mike Welles Date: Tue, 4 Apr 2000 14:54:34 +0000 Subject: [PATCH] * tif_win32.c: Applied patch to fix overreads and ovverwrites caught by BoundsChecker. From Arvan Pritchard --- ChangeLog | 10 ++++++++-- libtiff/tif_getimage.c | 14 +++++++------- libtiff/tif_win32.c | 29 +++++++++++++++++++---------- 3 files changed, 34 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index 315ce443..871604d0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,12 @@ 2000-04-04 Mike Welles - - * tif_lzw.c Applied patch to silence VC6 warnings. From + * tif_win32.c: Applied patch to fix overreads and ovverwrites + caught by BoundsChecker. From Arvan Pritchard + (untested). + + * tif_getimage.c: Applied patch to silence VC6 warnings. From + Arvan Pritchard + + * tif_lzw.c: Applied patch to silence VC6 warnings. From Arvan Pritchard 2000-03-28 Frank Warmerdam diff --git a/libtiff/tif_getimage.c b/libtiff/tif_getimage.c index 14e97dad..11e46332 100644 --- a/libtiff/tif_getimage.c +++ b/libtiff/tif_getimage.c @@ -1,4 +1,4 @@ -/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_getimage.c,v 1.4 1999-11-27 21:32:10 warmerda Exp $ */ +/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_getimage.c,v 1.5 2000-04-04 14:54:34 mwelles Exp $ */ /* * Copyright (c) 1991-1997 Sam Leffler @@ -1542,12 +1542,12 @@ initYCbCrConversion(TIFFRGBAImage* img) */ TIFFGetFieldDefaulted(img->tif, TIFFTAG_YCBCRSUBSAMPLING, &hs, &vs); switch ((hs<<4)|vs) { - case 0x44: return (putcontig8bitYCbCr44tile); - case 0x42: return (putcontig8bitYCbCr42tile); - case 0x41: return (putcontig8bitYCbCr41tile); - case 0x22: return (putcontig8bitYCbCr22tile); - case 0x21: return (putcontig8bitYCbCr21tile); - case 0x11: return (putcontig8bitYCbCr11tile); + case 0x44: return (&putcontig8bitYCbCr44tile); + case 0x42: return (&putcontig8bitYCbCr42tile); + case 0x41: return (&putcontig8bitYCbCr41tile); + case 0x22: return (&putcontig8bitYCbCr22tile); + case 0x21: return (&putcontig8bitYCbCr21tile); + case 0x11: return (&putcontig8bitYCbCr11tile); } return (NULL); } diff --git a/libtiff/tif_win32.c b/libtiff/tif_win32.c index 1a3afa1c..b9e277d5 100644 --- a/libtiff/tif_win32.c +++ b/libtiff/tif_win32.c @@ -1,4 +1,4 @@ -/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_win32.c,v 1.5 2000-01-28 21:42:48 warmerda Exp $ */ +/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_win32.c,v 1.6 2000-04-04 14:54:34 mwelles Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -152,7 +152,7 @@ TIFF* TIFFFdOpen(int ifd, const char* name, const char* mode) { TIFF* tif; - BOOL fSuppressMap = (mode[1] == 'u' || mode[2] == 'u'); + BOOL fSuppressMap = (mode[1] == 'u' || (mode[1]!=0 && mode[2] == 'u')); tif = TIFFClientOpen(name, mode, (thandle_t)ifd, @@ -224,14 +224,23 @@ _TIFFfree(tdata_t p) tdata_t _TIFFrealloc(tdata_t p, tsize_t s) { - void* pvTmp; - if ((pvTmp = GlobalReAlloc(p, s, 0)) == NULL) { - if ((pvTmp = GlobalAlloc(GMEM_FIXED, s)) != NULL) { - CopyMemory(pvTmp, p, GlobalSize(p)); - GlobalFree(p); - } - } - return ((tdata_t)pvTmp); + void* pvTmp; + tsize_t old=GlobalSize(p); + if (old>=s) + { + if ((pvTmp = GlobalAlloc(GMEM_FIXED, s)) != NULL) { + CopyMemory(pvTmp, p, s); + GlobalFree(p); + } + } + else + { + if ((pvTmp = GlobalAlloc(GMEM_FIXED, s)) != NULL) { + CopyMemory(pvTmp, p, old); + GlobalFree(p); + } + } + return ((tdata_t)pvTmp); } void