diff --git a/headers/libs/tiff/tiff.h b/headers/libs/tiff/tiff.h index 5eddf65689..ca3feda95b 100644 --- a/headers/libs/tiff/tiff.h +++ b/headers/libs/tiff/tiff.h @@ -1,4 +1,4 @@ -/* $Id: tiff.h,v 1.43 2006-10-05 15:20:40 dron Exp $ */ +/* $Id: tiff.h,v 1.43.2.1 2010-06-08 18:50:43 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -651,3 +651,10 @@ typedef enum { #endif /* _TIFF_ */ /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/headers/libs/tiff/tiffio.h b/headers/libs/tiff/tiffio.h index f4623e137d..06ec25c829 100644 --- a/headers/libs/tiff/tiffio.h +++ b/headers/libs/tiff/tiffio.h @@ -1,4 +1,4 @@ -/* $Id: tiffio.h,v 1.56.2.3 2009-01-01 00:10:43 bfriesen Exp $ */ +/* $Id: tiffio.h,v 1.56.2.4 2010-06-08 18:50:43 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -517,3 +517,10 @@ extern void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *, uint32, int32, int32, #endif /* _TIFFIO_ */ /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/headers/libs/tiff/tiffvers.h b/headers/libs/tiff/tiffvers.h index 7108541bc2..314a22a0ae 100644 --- a/headers/libs/tiff/tiffvers.h +++ b/headers/libs/tiff/tiffvers.h @@ -1,4 +1,4 @@ -#define TIFFLIB_VERSION_STR "LIBTIFF, Version 3.9.2\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc." +#define TIFFLIB_VERSION_STR "LIBTIFF, Version 3.9.4\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc." /* * This define can be used in code that requires * compilation-related definitions specific to a @@ -6,4 +6,4 @@ * version checking should be done based on the * string returned by TIFFGetVersion. */ -#define TIFFLIB_VERSION 20091104 +#define TIFFLIB_VERSION 20100615 diff --git a/src/libs/tiff/mkg3states.c b/src/libs/tiff/mkg3states.c index dd29ec82b7..7f4346b7f3 100644 --- a/src/libs/tiff/mkg3states.c +++ b/src/libs/tiff/mkg3states.c @@ -1,4 +1,4 @@ -/* "$Id: mkg3states.c,v 1.10 2007/02/22 11:27:17 dron Exp $ */ +/* "$Id: mkg3states.c,v 1.10.2.1 2010-06-08 18:50:41 bfriesen Exp $ */ /* * Copyright (c) 1991-1997 Sam Leffler @@ -442,3 +442,10 @@ main(int argc, char* argv[]) } /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/src/libs/tiff/t4.h b/src/libs/tiff/t4.h index 10bb17a5cb..870704ffe8 100644 --- a/src/libs/tiff/t4.h +++ b/src/libs/tiff/t4.h @@ -1,4 +1,4 @@ -/* $Id: t4.h,v 1.1.1.1 1999/07/27 21:50:27 mike Exp $ */ +/* $Id: t4.h,v 1.1.1.1.2.1 2010-06-08 18:50:41 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -283,3 +283,10 @@ extern const tableentry TIFFFaxWhiteCodes[]; extern const tableentry TIFFFaxBlackCodes[]; #endif #endif /* _T4_ */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/src/libs/tiff/tif_aux.c b/src/libs/tiff/tif_aux.c index 43d591b38a..272f0d9b68 100644 --- a/src/libs/tiff/tif_aux.c +++ b/src/libs/tiff/tif_aux.c @@ -1,4 +1,4 @@ -/* $Id: tif_aux.c,v 1.20 2006/06/08 14:24:13 dron Exp $ */ +/* $Id: tif_aux.c,v 1.20.2.3 2010-06-09 21:15:27 bfriesen Exp $ */ /* * Copyright (c) 1991-1997 Sam Leffler @@ -48,7 +48,9 @@ _TIFFCheckRealloc(TIFF* tif, tdata_t buffer, if (cp == NULL) TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "No space %s", what); + "Failed to allocate memory for %s " + "(%ld elements of %ld bytes each)", + what,(long) nmemb, (long) elem_size); return cp; } @@ -100,6 +102,35 @@ bad: return 0; } +static int +TIFFDefaultRefBlackWhite(TIFFDirectory* td) +{ + int i; + + if (!(td->td_refblackwhite = (float *)_TIFFmalloc(6*sizeof (float)))) + return 0; + if (td->td_photometric == PHOTOMETRIC_YCBCR) { + /* + * YCbCr (Class Y) images must have the ReferenceBlackWhite + * tag set. Fix the broken images, which lacks that tag. + */ + td->td_refblackwhite[0] = 0.0F; + td->td_refblackwhite[1] = td->td_refblackwhite[3] = + td->td_refblackwhite[5] = 255.0F; + td->td_refblackwhite[2] = td->td_refblackwhite[4] = 128.0F; + } else { + /* + * Assume RGB (Class R) + */ + for (i = 0; i < 3; i++) { + td->td_refblackwhite[2*i+0] = 0; + td->td_refblackwhite[2*i+1] = + (float)((1L<td_bitspersample)-1L); + } + } + return 1; +} + /* * Like TIFFGetField, but return any default * value if the tag is not present in the directory. @@ -225,33 +256,10 @@ TIFFVGetFieldDefaulted(TIFF* tif, ttag_t tag, va_list ap) } return (1); case TIFFTAG_REFERENCEBLACKWHITE: - { - int i; - static float ycbcr_refblackwhite[] = - { 0.0F, 255.0F, 128.0F, 255.0F, 128.0F, 255.0F }; - static float rgb_refblackwhite[6]; - - for (i = 0; i < 3; i++) { - rgb_refblackwhite[2 * i + 0] = 0.0F; - rgb_refblackwhite[2 * i + 1] = - (float)((1L<td_bitspersample)-1L); - } - - if (td->td_photometric == PHOTOMETRIC_YCBCR) { - /* - * YCbCr (Class Y) images must have the - * ReferenceBlackWhite tag set. Fix the - * broken images, which lacks that tag. - */ - *va_arg(ap, float **) = ycbcr_refblackwhite; - } else { - /* - * Assume RGB (Class R) - */ - *va_arg(ap, float **) = rgb_refblackwhite; - } - return 1; - } + if (!td->td_refblackwhite && !TIFFDefaultRefBlackWhite(td)) + return (0); + *va_arg(ap, float **) = td->td_refblackwhite; + return (1); } return 0; } @@ -273,3 +281,10 @@ TIFFGetFieldDefaulted(TIFF* tif, ttag_t tag, ...) } /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/src/libs/tiff/tif_close.c b/src/libs/tiff/tif_close.c index 3623277414..02591ba978 100644 --- a/src/libs/tiff/tif_close.c +++ b/src/libs/tiff/tif_close.c @@ -1,4 +1,4 @@ -/* $Id: tif_close.c,v 1.10 2006/03/25 03:09:24 joris Exp $ */ +/* $Id: tif_close.c,v 1.10.2.1 2010-06-08 18:50:41 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -117,3 +117,10 @@ TIFFClose(TIFF* tif) (void) (*closeproc)(fd); } +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/src/libs/tiff/tif_codec.c b/src/libs/tiff/tif_codec.c index 02fb839b2f..d5c6fd1149 100644 --- a/src/libs/tiff/tif_codec.c +++ b/src/libs/tiff/tif_codec.c @@ -1,4 +1,4 @@ -/* $Id: tif_codec.c,v 1.10.2.1 2008-12-18 19:50:41 fwarmerdam Exp $ */ +/* $Id: tif_codec.c,v 1.10.2.2 2010-06-08 18:50:41 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -151,3 +151,10 @@ TIFFIsCODECConfigured(uint16 scheme) return 0; } +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/src/libs/tiff/tif_color.c b/src/libs/tiff/tif_color.c index 0f484aa7cc..02eb346b06 100644 --- a/src/libs/tiff/tif_color.c +++ b/src/libs/tiff/tif_color.c @@ -1,4 +1,4 @@ -/* $Id: tif_color.c,v 1.12 2006/02/09 15:42:20 dron Exp $ */ +/* $Id: tif_color.c,v 1.12.2.1 2010-06-08 18:50:41 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -273,3 +273,10 @@ TIFFYCbCrToRGBInit(TIFFYCbCrToRGB* ycbcr, float *luma, float *refBlackWhite) #undef FIX /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/src/libs/tiff/tif_compress.c b/src/libs/tiff/tif_compress.c index 6c3f322cf7..0ce509b0bd 100644 --- a/src/libs/tiff/tif_compress.c +++ b/src/libs/tiff/tif_compress.c @@ -1,4 +1,4 @@ -/* $Id: tif_compress.c,v 1.13 2007/02/24 15:03:50 dron Exp $ */ +/* $Id: tif_compress.c,v 1.13.2.1 2010-06-08 18:50:41 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -286,3 +286,10 @@ TIFFGetConfiguredCODECs() } /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/src/libs/tiff/tif_dir.c b/src/libs/tiff/tif_dir.c index 102c9a85cd..ac44b381f8 100644 --- a/src/libs/tiff/tif_dir.c +++ b/src/libs/tiff/tif_dir.c @@ -1,4 +1,4 @@ -/* $Id: tif_dir.c,v 1.75.2.2 2009-01-01 00:10:43 bfriesen Exp $ */ +/* $Id: tif_dir.c,v 1.75.2.5 2010-06-09 21:15:27 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -377,6 +377,10 @@ _TIFFVSetField(TIFF* tif, ttag_t tag, va_list ap) _TIFFsetShortArray(&td->td_transferfunction[i], va_arg(ap, uint16*), 1L<td_bitspersample); break; + case TIFFTAG_REFERENCEBLACKWHITE: + /* XXX should check for null range */ + _TIFFsetFloatArray(&td->td_refblackwhite, va_arg(ap, float*), 6); + break; case TIFFTAG_INKNAMES: v = va_arg(ap, uint32); s = va_arg(ap, char*); @@ -815,6 +819,9 @@ _TIFFVGetField(TIFF* tif, ttag_t tag, va_list ap) *va_arg(ap, uint16**) = td->td_transferfunction[2]; } break; + case TIFFTAG_REFERENCEBLACKWHITE: + *va_arg(ap, float**) = td->td_refblackwhite; + break; case TIFFTAG_INKNAMES: *va_arg(ap, char**) = td->td_inknames; break; @@ -989,6 +996,7 @@ TIFFFreeDirectory(TIFF* tif) CleanupField(td_sampleinfo); CleanupField(td_subifd); CleanupField(td_inknames); + CleanupField(td_refblackwhite); CleanupField(td_transferfunction[0]); CleanupField(td_transferfunction[1]); CleanupField(td_transferfunction[2]); @@ -1099,6 +1107,11 @@ TIFFDefaultDirectory(TIFF* tif) * Should we also be clearing stuff like INSUBIFD? */ tif->tif_flags &= ~TIFF_ISTILED; + /* + * Clear other directory-specific fields. + */ + tif->tif_tilesize = -1; + tif->tif_scanlinesize = -1; return (1); } @@ -1367,3 +1380,10 @@ TIFFReassignTagToIgnore (enum TIFFIgnoreSense task, int TIFFtagID) } /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/src/libs/tiff/tif_dir.h b/src/libs/tiff/tif_dir.h index e2aeea2917..515af19942 100644 --- a/src/libs/tiff/tif_dir.h +++ b/src/libs/tiff/tif_dir.h @@ -1,4 +1,4 @@ -/* $Id: tif_dir.h,v 1.30.2.1 2007/04/07 14:58:30 dron Exp $ */ +/* $Id: tif_dir.h,v 1.30.2.3 2010-06-09 21:15:27 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -75,6 +75,7 @@ typedef struct { uint16 td_ycbcrsubsampling[2]; uint16 td_ycbcrpositioning; /* Colorimetry parameters */ + float* td_refblackwhite; uint16* td_transferfunction[3]; /* CMYK parameters */ int td_inknameslen; @@ -133,6 +134,7 @@ typedef struct { #define FIELD_HALFTONEHINTS 37 #define FIELD_YCBCRSUBSAMPLING 39 #define FIELD_YCBCRPOSITIONING 40 +#define FIELD_REFBLACKWHITE 41 #define FIELD_TRANSFERFUNCTION 44 #define FIELD_INKNAMES 46 #define FIELD_SUBIFD 49 @@ -200,3 +202,10 @@ extern TIFFFieldInfo* _TIFFCreateAnonFieldInfo( TIFF *tif, ttag_t tag, #endif /* _TIFFDIR_ */ /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/src/libs/tiff/tif_dirinfo.c b/src/libs/tiff/tif_dirinfo.c index 99a871cc37..0a77c9714e 100644 --- a/src/libs/tiff/tif_dirinfo.c +++ b/src/libs/tiff/tif_dirinfo.c @@ -1,4 +1,4 @@ -/* $Id: tif_dirinfo.c,v 1.65.2.7 2009-09-17 18:00:28 bfriesen Exp $ */ +/* $Id: tif_dirinfo.c,v 1.65.2.9 2010-06-09 21:15:27 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -217,10 +217,10 @@ tiffFieldInfo[] = { 0, 0, "YCbCrSubsampling" }, { TIFFTAG_YCBCRPOSITIONING, 1, 1, TIFF_SHORT, FIELD_YCBCRPOSITIONING, 0, 0, "YCbCrPositioning" }, - { TIFFTAG_REFERENCEBLACKWHITE, 6, 6, TIFF_RATIONAL, FIELD_CUSTOM, + { TIFFTAG_REFERENCEBLACKWHITE, 6, 6, TIFF_RATIONAL, FIELD_REFBLACKWHITE, 1, 0, "ReferenceBlackWhite" }, /* XXX temporarily accept LONG for backwards compatibility */ - { TIFFTAG_REFERENCEBLACKWHITE, 6, 6, TIFF_LONG, FIELD_CUSTOM, + { TIFFTAG_REFERENCEBLACKWHITE, 6, 6, TIFF_LONG, FIELD_REFBLACKWHITE, 1, 0, "ReferenceBlackWhite" }, { TIFFTAG_XMLPACKET, -3,-3, TIFF_BYTE, FIELD_CUSTOM, 0, 1, "XMLPacket" }, @@ -879,3 +879,10 @@ _TIFFCreateAnonFieldInfo(TIFF *tif, ttag_t tag, TIFFDataType field_type) } /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/src/libs/tiff/tif_dirread.c b/src/libs/tiff/tif_dirread.c index 52d53fc3ce..907b53188c 100644 --- a/src/libs/tiff/tif_dirread.c +++ b/src/libs/tiff/tif_dirread.c @@ -1,4 +1,4 @@ -/* $Id: tif_dirread.c,v 1.92.2.6 2009-10-29 20:04:32 bfriesen Exp $ */ +/* $Id: tif_dirread.c,v 1.92.2.9 2010-06-14 00:21:46 fwarmerdam Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -84,6 +84,7 @@ TIFFReadDirectory(TIFF* tif) size_t fix; uint16 dircount; int diroutoforderwarning = 0, compressionknown = 0; + int haveunknowntags = 0; tif->tif_diroff = tif->tif_nextdiroff; /* @@ -160,8 +161,10 @@ TIFFReadDirectory(TIFF* tif) fix = 0; for (dp = dir, n = dircount; n > 0; n--, dp++) { - if (fix >= tif->tif_nfields || dp->tdir_tag == IGNORE) + if (dp->tdir_tag == IGNORE) continue; + if (fix >= tif->tif_nfields) + fix = 0; /* * Silicon Beach (at least) writes unordered @@ -182,31 +185,9 @@ TIFFReadDirectory(TIFF* tif) fix++; if (fix >= tif->tif_nfields || tif->tif_fieldinfo[fix]->field_tag != dp->tdir_tag) { - - TIFFWarningExt(tif->tif_clientdata, - module, - "%s: unknown field with tag %d (0x%x) encountered", - tif->tif_name, - dp->tdir_tag, - dp->tdir_tag); - - if (!_TIFFMergeFieldInfo(tif, - _TIFFCreateAnonFieldInfo(tif, - dp->tdir_tag, - (TIFFDataType) dp->tdir_type), - 1)) - { - TIFFWarningExt(tif->tif_clientdata, - module, - "Registering anonymous field with tag %d (0x%x) failed", - dp->tdir_tag, - dp->tdir_tag); - goto ignore; - } - fix = 0; - while (fix < tif->tif_nfields && - tif->tif_fieldinfo[fix]->field_tag < dp->tdir_tag) - fix++; + /* Unknown tag ... we'll deal with it below */ + haveunknowntags = 1; + continue; } /* * Null out old tags that we ignore. @@ -296,6 +277,76 @@ TIFFReadDirectory(TIFF* tif) } } + /* + * If we saw any unknown tags, make an extra pass over the directory + * to deal with them. This must be done separately because the tags + * could have become known when we registered a codec after finding + * the Compression tag. In a correctly-sorted directory there's + * no problem because Compression will come before any codec-private + * tags, but if the sorting is wrong that might not hold. + */ + if (haveunknowntags) { + fix = 0; + for (dp = dir, n = dircount; n > 0; n--, dp++) { + if (dp->tdir_tag == IGNORE) + continue; + if (fix >= tif->tif_nfields || + dp->tdir_tag < tif->tif_fieldinfo[fix]->field_tag) + fix = 0; /* O(n^2) */ + while (fix < tif->tif_nfields && + tif->tif_fieldinfo[fix]->field_tag < dp->tdir_tag) + fix++; + if (fix >= tif->tif_nfields || + tif->tif_fieldinfo[fix]->field_tag != dp->tdir_tag) { + + TIFFWarningExt(tif->tif_clientdata, + module, + "%s: unknown field with tag %d (0x%x) encountered", + tif->tif_name, + dp->tdir_tag, + dp->tdir_tag); + + if (!_TIFFMergeFieldInfo(tif, + _TIFFCreateAnonFieldInfo(tif, + dp->tdir_tag, + (TIFFDataType) dp->tdir_type), + 1)) + { + TIFFWarningExt(tif->tif_clientdata, + module, + "Registering anonymous field with tag %d (0x%x) failed", + dp->tdir_tag, + dp->tdir_tag); + dp->tdir_tag = IGNORE; + continue; + } + fix = 0; + while (fix < tif->tif_nfields && + tif->tif_fieldinfo[fix]->field_tag < dp->tdir_tag) + fix++; + } + /* + * Check data type. + */ + fip = tif->tif_fieldinfo[fix]; + while (dp->tdir_type != (unsigned short) fip->field_type + && fix < tif->tif_nfields) { + if (fip->field_type == TIFF_ANY) /* wildcard */ + break; + fip = tif->tif_fieldinfo[++fix]; + if (fix >= tif->tif_nfields || + fip->field_tag != dp->tdir_tag) { + TIFFWarningExt(tif->tif_clientdata, module, + "%s: wrong data type %d for \"%s\"; tag ignored", + tif->tif_name, dp->tdir_type, + tif->tif_fieldinfo[fix-1]->field_name); + dp->tdir_tag = IGNORE; + break; + } + } + } + } + /* * XXX: OJPEG hack. * If a) compression is OJPEG, b) planarconfig tag says it's separate, @@ -1919,6 +1970,13 @@ TIFFFetchSubjectDistance(TIFF* tif, TIFFDirEntry* dir) float v; int ok = 0; + if( dir->tdir_count != 1 || dir->tdir_type != TIFF_RATIONAL ) + { + TIFFWarningExt(tif->tif_clientdata, tif->tif_name, + "incorrect count or type for SubjectDistance, tag ignored" ); + return (0); + } + if (TIFFFetchData(tif, dir, (char *)l) && cvtRational(tif, dir, l[0], l[1], &v)) { /* @@ -2014,3 +2072,10 @@ ChopUpSingleUncompressedStrip(TIFF* tif) } /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/src/libs/tiff/tif_dirwrite.c b/src/libs/tiff/tif_dirwrite.c index 5148097dc3..8d308c4292 100644 --- a/src/libs/tiff/tif_dirwrite.c +++ b/src/libs/tiff/tif_dirwrite.c @@ -1,4 +1,4 @@ -/* $Id: tif_dirwrite.c,v 1.37.2.6 2009-10-31 21:51:08 bfriesen Exp $ */ +/* $Id: tif_dirwrite.c,v 1.37.2.7 2010-06-08 18:50:42 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -1405,3 +1405,10 @@ TIFFLinkDirectory(TIFF* tif) } /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/src/libs/tiff/tif_dumpmode.c b/src/libs/tiff/tif_dumpmode.c index 767d6d9263..da861503d8 100644 --- a/src/libs/tiff/tif_dumpmode.c +++ b/src/libs/tiff/tif_dumpmode.c @@ -1,4 +1,4 @@ -/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_dumpmode.c,v 1.5.2.1 2009-01-01 00:10:43 bfriesen Exp $ */ +/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_dumpmode.c,v 1.5.2.2 2010-06-08 18:50:42 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -117,3 +117,10 @@ TIFFInitDumpMode(TIFF* tif, int scheme) tif->tif_seek = DumpModeSeek; return (1); } +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/src/libs/tiff/tif_error.c b/src/libs/tiff/tif_error.c index 7025080ed3..2377abda87 100644 --- a/src/libs/tiff/tif_error.c +++ b/src/libs/tiff/tif_error.c @@ -1,4 +1,4 @@ -/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_error.c,v 1.4 2005/12/23 01:18:59 joris Exp $ */ +/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_error.c,v 1.4.2.1 2010-06-08 18:50:42 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -71,3 +71,10 @@ TIFFErrorExt(thandle_t fd, const char* module, const char* fmt, ...) va_end(ap); } +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/src/libs/tiff/tif_extension.c b/src/libs/tiff/tif_extension.c index 6861522285..b67c0f00be 100644 --- a/src/libs/tiff/tif_extension.c +++ b/src/libs/tiff/tif_extension.c @@ -1,4 +1,4 @@ -/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_extension.c,v 1.4 2004/10/02 13:29:41 dron Exp $ */ +/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_extension.c,v 1.4.2.1 2010-06-08 18:50:42 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -109,3 +109,10 @@ void TIFFSetClientInfo( TIFF *tif, void *data, const char *name ) tif->tif_clientinfo = link; } +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/src/libs/tiff/tif_fax3.c b/src/libs/tiff/tif_fax3.c index b560d56415..9eec4ab7b7 100644 --- a/src/libs/tiff/tif_fax3.c +++ b/src/libs/tiff/tif_fax3.c @@ -1,4 +1,4 @@ -/* $Id: tif_fax3.c,v 1.43.2.5 2009-01-01 00:10:43 bfriesen Exp $ */ +/* $Id: tif_fax3.c,v 1.43.2.10 2010-06-09 17:16:58 bfriesen Exp $ */ /* * Copyright (c) 1990-1997 Sam Leffler @@ -493,10 +493,26 @@ Fax3SetupState(TIFF* tif) td->td_compression == COMPRESSION_CCITTFAX4 ); - nruns = needsRefLine ? 2*TIFFroundup(rowpixels,32) : rowpixels; - nruns += 3; - dsp->runs = (uint32*) _TIFFCheckMalloc(tif, 2*nruns, sizeof (uint32), - "for Group 3/4 run arrays"); + /* + Assure that allocation computations do not overflow. + + TIFFroundup and TIFFSafeMultiply return zero on integer overflow + */ + dsp->runs=(uint32*) NULL; + nruns = TIFFroundup(rowpixels,32); + if (needsRefLine) { + nruns = TIFFSafeMultiply(uint32,nruns,2); + } + if ((nruns == 0) || (TIFFSafeMultiply(uint32,nruns,2) == 0)) { + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + "Row pixels integer overflow (rowpixels %u)", + rowpixels); + return (0); + } + dsp->runs = (uint32*) _TIFFCheckMalloc(tif, + TIFFSafeMultiply(uint32,nruns,2), + sizeof (uint32), + "for Group 3/4 run arrays"); if (dsp->runs == NULL) return (0); dsp->curruns = dsp->runs; @@ -1439,12 +1455,12 @@ Fax4Decode(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) BADG4: #ifdef FAX3_DEBUG if( GetBits(13) != 0x1001 ) - fputs( "Bad RTC\n", stderr ); + fputs( "Bad EOFB\n", stderr ); #endif ClrBits( 13 ); (*sp->fill)(buf, thisrun, pa, lastx); UNCACHE_STATE(tif, sp); - return (-1); + return ( sp->line ? 1 : -1); /* don't error on badly-terminated strips */ } UNCACHE_STATE(tif, sp); return (1); @@ -1601,3 +1617,10 @@ TIFFInitCCITTRLEW(TIFF* tif, int scheme) #endif /* CCITT_SUPPORT */ /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/src/libs/tiff/tif_fax3.h b/src/libs/tiff/tif_fax3.h index 030632f80a..40718bcfa7 100644 --- a/src/libs/tiff/tif_fax3.h +++ b/src/libs/tiff/tif_fax3.h @@ -1,4 +1,4 @@ -/* $Id: tif_fax3.h,v 1.5 2005/12/12 09:23:11 dron Exp $ */ +/* $Id: tif_fax3.h,v 1.5.2.1 2010-06-08 18:50:42 bfriesen Exp $ */ /* * Copyright (c) 1990-1997 Sam Leffler @@ -523,3 +523,10 @@ eol2d: \ CLEANUP_RUNS(); \ } while (0) #endif /* _FAX3_ */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/src/libs/tiff/tif_fax3sm.c b/src/libs/tiff/tif_fax3sm.c index 08ce1ad608..822191ecf4 100644 --- a/src/libs/tiff/tif_fax3sm.c +++ b/src/libs/tiff/tif_fax3sm.c @@ -1251,3 +1251,10 @@ {8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3}, {8,3,4},{8,2,2} }; +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/src/libs/tiff/tif_flush.c b/src/libs/tiff/tif_flush.c index 5ff56e9a81..7ecc4d8345 100644 --- a/src/libs/tiff/tif_flush.c +++ b/src/libs/tiff/tif_flush.c @@ -1,4 +1,4 @@ -/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_flush.c,v 1.3 2000/09/15 20:52:42 warmerda Exp $ */ +/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_flush.c,v 1.3.2.1 2010-06-08 18:50:42 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -65,3 +65,10 @@ TIFFFlushData(TIFF* tif) return (TIFFFlushData1(tif)); } +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/src/libs/tiff/tif_getimage.c b/src/libs/tiff/tif_getimage.c index 667f32380a..38455fbc07 100644 --- a/src/libs/tiff/tif_getimage.c +++ b/src/libs/tiff/tif_getimage.c @@ -1,4 +1,4 @@ -/* $Id: tif_getimage.c,v 1.63.2.3 2009-08-30 16:21:46 bfriesen Exp $ */ +/* $Id: tif_getimage.c,v 1.63.2.4 2010-06-08 18:50:42 bfriesen Exp $ */ /* * Copyright (c) 1991-1997 Sam Leffler @@ -2667,3 +2667,10 @@ TIFFReadRGBATile(TIFF* tif, uint32 col, uint32 row, uint32 * raster) } /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/src/libs/tiff/tif_jbig.c b/src/libs/tiff/tif_jbig.c index 99183ba74e..c92ee3de6c 100644 --- a/src/libs/tiff/tif_jbig.c +++ b/src/libs/tiff/tif_jbig.c @@ -1,4 +1,4 @@ -/* $Id: tif_jbig.c,v 1.2.2.2 2008-10-21 13:13:07 dron Exp $ */ +/* $Id: tif_jbig.c,v 1.2.2.3 2010-06-08 18:50:42 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -376,3 +376,10 @@ int TIFFInitJBIG(TIFF* tif, int scheme) /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/src/libs/tiff/tif_jpeg.c b/src/libs/tiff/tif_jpeg.c index 74b0d3f860..a967827e74 100644 --- a/src/libs/tiff/tif_jpeg.c +++ b/src/libs/tiff/tif_jpeg.c @@ -1,4 +1,4 @@ -/* $Id: tif_jpeg.c,v 1.50.2.4 2009-08-30 16:21:46 bfriesen Exp $ */ +/* $Id: tif_jpeg.c,v 1.50.2.9 2010-06-14 02:47:16 fwarmerdam Exp $ */ /* * Copyright (c) 1994-1997 Sam Leffler @@ -1269,12 +1269,16 @@ JPEGSetupEncode(TIFF* tif) /* Create a JPEGTables field if appropriate */ if (sp->jpegtablesmode & (JPEGTABLESMODE_QUANT|JPEGTABLESMODE_HUFF)) { - if (!prepare_JPEGTables(tif)) - return (0); - /* Mark the field present */ - /* Can't use TIFFSetField since BEENWRITING is already set! */ - TIFFSetFieldBit(tif, FIELD_JPEGTABLES); - tif->tif_flags |= TIFF_DIRTYDIRECT; + if( sp->jpegtables == NULL + || memcmp(sp->jpegtables,"\0\0\0\0\0\0\0\0\0",8) == 0 ) + { + if (!prepare_JPEGTables(tif)) + return (0); + /* Mark the field present */ + /* Can't use TIFFSetField since BEENWRITING is already set! */ + tif->tif_flags |= TIFF_DIRTYDIRECT; + TIFFSetFieldBit(tif, FIELD_JPEGTABLES); + } } else { /* We do not support application-supplied JPEGTables, */ /* so mark the field not present */ @@ -1370,9 +1374,9 @@ JPEGPreEncode(TIFF* tif, tsample_t s) sp->cinfo.c.write_JFIF_header = FALSE; sp->cinfo.c.write_Adobe_marker = FALSE; /* set up table handling correctly */ + if (!TIFFjpeg_set_quality(sp, sp->jpegquality, FALSE)) + return (0); if (! (sp->jpegtablesmode & JPEGTABLESMODE_QUANT)) { - if (!TIFFjpeg_set_quality(sp, sp->jpegquality, FALSE)) - return (0); unsuppress_quant_table(sp, 0); unsuppress_quant_table(sp, 1); } @@ -1613,7 +1617,11 @@ JPEGResetUpsampled( TIFF* tif ) * Must recalculate cached tile size in case sampling state changed. * Should we really be doing this now if image size isn't set? */ - tif->tif_tilesize = isTiled(tif) ? TIFFTileSize(tif) : (tsize_t) -1; + if( tif->tif_tilesize > 0 ) + tif->tif_tilesize = isTiled(tif) ? TIFFTileSize(tif) : (tsize_t) -1; + + if(tif->tif_scanlinesize > 0 ) + tif->tif_scanlinesize = TIFFScanlineSize(tif); } static int @@ -1741,13 +1749,21 @@ JPEGFixupTestSubsampling( TIFF * tif ) return; } else - { + { if( !TIFFFillStrip( tif, 0 ) ) return; } TIFFSetField( tif, TIFFTAG_YCBCRSUBSAMPLING, (uint16) sp->h_sampling, (uint16) sp->v_sampling ); + + /* + ** We want to clear the loaded strip so the application has time + ** to set JPEGCOLORMODE or other behavior modifiers. This essentially + ** undoes the JPEGPreDecode triggers by TIFFFileStrip(). (#1936) + */ + tif->tif_curstrip = -1; + #endif /* CHECK_JPEG_YCBCR_SUBSAMPLING */ } @@ -2014,7 +2030,14 @@ TIFFInitJPEG(TIFF* tif, int scheme) if( tif->tif_diroff == 0 ) { #define SIZE_OF_JPEGTABLES 2000 +/* +The following line assumes incorrectly that all JPEG-in-TIFF files will have +a JPEGTABLES tag generated and causes null-filled JPEGTABLES tags to be written +when the JPEG data is placed with TIFFWriteRawStrip. The field bit should be +set, anyway, later when actual JPEGTABLES header is generated, so removing it +here hopefully is harmless. TIFFSetFieldBit(tif, FIELD_JPEGTABLES); +*/ sp->jpegtables_length = SIZE_OF_JPEGTABLES; sp->jpegtables = (void *) _TIFFmalloc(sp->jpegtables_length); _TIFFmemset(sp->jpegtables, 0, SIZE_OF_JPEGTABLES); @@ -2033,3 +2056,10 @@ TIFFInitJPEG(TIFF* tif, int scheme) /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/src/libs/tiff/tif_luv.c b/src/libs/tiff/tif_luv.c index be8fceaf86..eb622b9b0b 100644 --- a/src/libs/tiff/tif_luv.c +++ b/src/libs/tiff/tif_luv.c @@ -1,4 +1,4 @@ -/* $Id: tif_luv.c,v 1.17.2.3 2009-06-30 17:06:25 fwarmerdam Exp $ */ +/* $Id: tif_luv.c,v 1.17.2.4 2010-06-08 18:50:42 bfriesen Exp $ */ /* * Copyright (c) 1997 Greg Ward Larson @@ -1620,3 +1620,10 @@ bad: #endif /* LOGLUV_SUPPORT */ /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/src/libs/tiff/tif_lzw.c b/src/libs/tiff/tif_lzw.c index bc4dac6537..d423866359 100644 --- a/src/libs/tiff/tif_lzw.c +++ b/src/libs/tiff/tif_lzw.c @@ -1,4 +1,4 @@ -/* $Id: tif_lzw.c,v 1.29.2.5 2009-06-22 04:57:31 fwarmerdam Exp $ */ +/* $Id: tif_lzw.c,v 1.29.2.6 2010-06-08 18:50:42 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -1120,3 +1120,10 @@ bad: #endif /* LZW_SUPPORT */ /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/src/libs/tiff/tif_next.c b/src/libs/tiff/tif_next.c index 0e1842d872..d7652bb4c1 100644 --- a/src/libs/tiff/tif_next.c +++ b/src/libs/tiff/tif_next.c @@ -1,4 +1,4 @@ -/* $Id: tif_next.c,v 1.8 2006/10/12 15:00:49 dron Exp $ */ +/* $Id: tif_next.c,v 1.8.2.1 2010-06-08 18:50:42 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -145,3 +145,10 @@ TIFFInitNeXT(TIFF* tif, int scheme) #endif /* NEXT_SUPPORT */ /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/src/libs/tiff/tif_ojpeg.c b/src/libs/tiff/tif_ojpeg.c index 9d1e8043e8..9ae856cfde 100644 --- a/src/libs/tiff/tif_ojpeg.c +++ b/src/libs/tiff/tif_ojpeg.c @@ -1,4 +1,4 @@ -/* $Id: tif_ojpeg.c,v 1.24.2.4 2009-09-03 20:45:10 bfriesen Exp $ */ +/* $Id: tif_ojpeg.c,v 1.24.2.6 2010-06-08 23:29:51 bfriesen Exp $ */ /* WARNING: The type of JPEG encapsulation defined by the TIFF Version 6.0 specification is now totally obsolete and deprecated for new applications and @@ -1909,6 +1909,10 @@ OJPEGReadBufferFill(OJPEGState* sp) sp->in_buffer_source=osibsEof; else { + if (sp->tif->tif_dir.td_stripoffset == 0) { + TIFFErrorExt(sp->tif->tif_clientdata,sp->tif->tif_name,"Strip offsets are missing"); + return(0); + } sp->in_buffer_file_pos=sp->tif->tif_dir.td_stripoffset[sp->in_buffer_next_strile]; if (sp->in_buffer_file_pos!=0) { @@ -2425,3 +2429,10 @@ OJPEGLibjpegJpegSourceMgrTermSource(jpeg_decompress_struct* cinfo) #endif +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/src/libs/tiff/tif_open.c b/src/libs/tiff/tif_open.c index a567056ce7..3b3b2ce67b 100644 --- a/src/libs/tiff/tif_open.c +++ b/src/libs/tiff/tif_open.c @@ -1,4 +1,4 @@ -/* $Id: tif_open.c,v 1.33 2006/06/08 14:27:17 dron Exp $ */ +/* $Id: tif_open.c,v 1.33.2.1 2010-06-08 18:50:42 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -686,3 +686,10 @@ TIFFGetUnmapFileProc(TIFF* tif) } /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/src/libs/tiff/tif_packbits.c b/src/libs/tiff/tif_packbits.c index 171a2692a8..ee095f568e 100644 --- a/src/libs/tiff/tif_packbits.c +++ b/src/libs/tiff/tif_packbits.c @@ -1,4 +1,4 @@ -/* $Id: tif_packbits.c,v 1.13.2.1 2009-01-01 00:10:43 bfriesen Exp $ */ +/* $Id: tif_packbits.c,v 1.13.2.2 2010-06-08 18:50:42 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -291,3 +291,10 @@ TIFFInitPackBits(TIFF* tif, int scheme) #endif /* PACKBITS_SUPPORT */ /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/src/libs/tiff/tif_pixarlog.c b/src/libs/tiff/tif_pixarlog.c index 5ad84f8b80..ed8eb4026f 100644 --- a/src/libs/tiff/tif_pixarlog.c +++ b/src/libs/tiff/tif_pixarlog.c @@ -1,4 +1,4 @@ -/* $Id: tif_pixarlog.c,v 1.15.2.3 2009-01-01 00:10:43 bfriesen Exp $ */ +/* $Id: tif_pixarlog.c,v 1.15.2.4 2010-06-08 18:50:42 bfriesen Exp $ */ /* * Copyright (c) 1996-1997 Sam Leffler @@ -1362,3 +1362,10 @@ bad: #endif /* PIXARLOG_SUPPORT */ /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/src/libs/tiff/tif_predict.c b/src/libs/tiff/tif_predict.c index 052a8e2f0a..bbc221f27f 100644 --- a/src/libs/tiff/tif_predict.c +++ b/src/libs/tiff/tif_predict.c @@ -1,4 +1,4 @@ -/* $Id: tif_predict.c,v 1.11.2.3 2009-01-23 15:57:18 fwarmerdam Exp $ */ +/* $Id: tif_predict.c,v 1.11.2.4 2010-06-08 18:50:42 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -727,3 +727,10 @@ TIFFPredictorCleanup(TIFF* tif) } /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/src/libs/tiff/tif_predict.h b/src/libs/tiff/tif_predict.h index 0c1aefccdc..da0ad9892b 100644 --- a/src/libs/tiff/tif_predict.h +++ b/src/libs/tiff/tif_predict.h @@ -1,4 +1,4 @@ -/* $Id: tif_predict.h,v 1.3.2.1 2007/11/22 21:24:51 fwarmerdam Exp $ */ +/* $Id: tif_predict.h,v 1.3.2.2 2010-06-08 18:50:42 bfriesen Exp $ */ /* * Copyright (c) 1995-1997 Sam Leffler @@ -68,3 +68,10 @@ extern int TIFFPredictorCleanup(TIFF*); #endif /* _TIFFPREDICT_ */ /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/src/libs/tiff/tif_print.c b/src/libs/tiff/tif_print.c index 871fffd614..eb4b1e70c3 100644 --- a/src/libs/tiff/tif_print.c +++ b/src/libs/tiff/tif_print.c @@ -1,4 +1,4 @@ -/* $Id: tif_print.c,v 1.36.2.2 2009-09-17 18:00:28 bfriesen Exp $ */ +/* $Id: tif_print.c,v 1.36.2.4 2010-06-08 18:50:42 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -144,7 +144,7 @@ _TIFFPrettyPrintField(TIFF* tif, FILE* fd, ttag_t tag, uint16 i; fprintf(fd, " Reference Black/White:\n"); - for (i = 0; i < td->td_samplesperpixel; i++) + for (i = 0; i < 3; i++) fprintf(fd, " %2d: %5g %5g\n", i, ((float *)raw_data)[2*i+0], ((float *)raw_data)[2*i+1]); @@ -637,3 +637,10 @@ _TIFFprintAsciiTag(FILE* fd, const char* name, const char* value) } /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/src/libs/tiff/tif_read.c b/src/libs/tiff/tif_read.c index 92e47469e2..8ac0ae66cb 100644 --- a/src/libs/tiff/tif_read.c +++ b/src/libs/tiff/tif_read.c @@ -1,4 +1,4 @@ -/* $Id: tif_read.c,v 1.16 2007/02/22 11:33:44 dron Exp $ */ +/* $Id: tif_read.c,v 1.16.2.3 2010-06-09 14:32:47 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -600,16 +600,18 @@ TIFFReadBufferSetup(TIFF* tif, tdata_t bp, tsize_t size) _TIFFfree(tif->tif_rawdata); tif->tif_rawdata = NULL; } + if (bp) { tif->tif_rawdatasize = size; tif->tif_rawdata = (tidata_t) bp; tif->tif_flags &= ~TIFF_MYBUFFER; } else { tif->tif_rawdatasize = TIFFroundup(size, 1024); - tif->tif_rawdata = (tidata_t) _TIFFmalloc(tif->tif_rawdatasize); + if (tif->tif_rawdatasize > 0) + tif->tif_rawdata = (tidata_t) _TIFFmalloc(tif->tif_rawdatasize); tif->tif_flags |= TIFF_MYBUFFER; } - if (tif->tif_rawdata == NULL) { + if ((tif->tif_rawdata == NULL) || (tif->tif_rawdatasize == 0)) { TIFFErrorExt(tif->tif_clientdata, module, "%s: No space for data buffer at scanline %ld", tif->tif_name, (long) tif->tif_row); @@ -739,3 +741,10 @@ _TIFFSwab64BitData(TIFF* tif, tidata_t buf, tsize_t cc) } /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/src/libs/tiff/tif_strip.c b/src/libs/tiff/tif_strip.c index 962d3fa7bc..63dec6bdac 100644 --- a/src/libs/tiff/tif_strip.c +++ b/src/libs/tiff/tif_strip.c @@ -1,4 +1,4 @@ -/* $Id: tif_strip.c,v 1.19 2006/03/25 18:04:35 joris Exp $ */ +/* $Id: tif_strip.c,v 1.19.2.1 2010-06-08 18:50:43 bfriesen Exp $ */ /* * Copyright (c) 1991-1997 Sam Leffler @@ -361,3 +361,10 @@ TIFFRasterScanlineSize(TIFF* tif) } /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/src/libs/tiff/tif_swab.c b/src/libs/tiff/tif_swab.c index 97cc88825c..e4f1a6d1e2 100644 --- a/src/libs/tiff/tif_swab.c +++ b/src/libs/tiff/tif_swab.c @@ -1,4 +1,4 @@ -/* $Id: tif_swab.c,v 1.4 2005/04/13 14:06:21 dron Exp $ */ +/* $Id: tif_swab.c,v 1.4.2.1 2010-06-08 18:50:43 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -233,3 +233,10 @@ TIFFReverseBits(register unsigned char* cp, register unsigned long n) } /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/src/libs/tiff/tif_thunder.c b/src/libs/tiff/tif_thunder.c index 94496eccb1..8e7a125841 100644 --- a/src/libs/tiff/tif_thunder.c +++ b/src/libs/tiff/tif_thunder.c @@ -1,4 +1,4 @@ -/* $Id: tif_thunder.c,v 1.5 2005/12/21 12:23:13 joris Exp $ */ +/* $Id: tif_thunder.c,v 1.5.2.1 2010-06-08 18:50:43 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -156,3 +156,10 @@ TIFFInitThunderScan(TIFF* tif, int scheme) #endif /* THUNDER_SUPPORT */ /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/src/libs/tiff/tif_tile.c b/src/libs/tiff/tif_tile.c index 454fe5cd24..d8379e61b3 100644 --- a/src/libs/tiff/tif_tile.c +++ b/src/libs/tiff/tif_tile.c @@ -1,4 +1,4 @@ -/* $Id: tif_tile.c,v 1.12 2006/02/09 16:15:43 dron Exp $ */ +/* $Id: tif_tile.c,v 1.12.2.1 2010-06-08 18:50:43 bfriesen Exp $ */ /* * Copyright (c) 1991-1997 Sam Leffler @@ -271,3 +271,10 @@ _TIFFDefaultTileSize(TIFF* tif, uint32* tw, uint32* th) } /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/src/libs/tiff/tif_unix.c b/src/libs/tiff/tif_unix.c index 28de5c9fe5..b73e80db1a 100644 --- a/src/libs/tiff/tif_unix.c +++ b/src/libs/tiff/tif_unix.c @@ -1,4 +1,4 @@ -/* $Id: tif_unix.c,v 1.12 2006/03/21 16:37:51 dron Exp $ */ +/* $Id: tif_unix.c,v 1.12.2.1 2010-06-08 18:50:43 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -291,3 +291,10 @@ unixErrorHandler(const char* module, const char* fmt, va_list ap) fprintf(stderr, ".\n"); } TIFFErrorHandler _TIFFerrorHandler = unixErrorHandler; +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/src/libs/tiff/tif_version.c b/src/libs/tiff/tif_version.c index 1264b71591..218dab566e 100644 --- a/src/libs/tiff/tif_version.c +++ b/src/libs/tiff/tif_version.c @@ -1,4 +1,4 @@ -/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_version.c,v 1.2 2000/11/13 14:42:38 warmerda Exp $ */ +/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_version.c,v 1.2.2.1 2010-06-08 18:50:43 bfriesen Exp $ */ /* * Copyright (c) 1992-1997 Sam Leffler * Copyright (c) 1992-1997 Silicon Graphics, Inc. @@ -31,3 +31,10 @@ TIFFGetVersion(void) { return (TIFFVersion); } +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/src/libs/tiff/tif_warning.c b/src/libs/tiff/tif_warning.c index d593469d2d..fe974d909f 100644 --- a/src/libs/tiff/tif_warning.c +++ b/src/libs/tiff/tif_warning.c @@ -1,4 +1,4 @@ -/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_warning.c,v 1.2 2005/12/23 01:18:59 joris Exp $ */ +/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_warning.c,v 1.2.2.1 2010-06-08 18:50:43 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -72,3 +72,10 @@ TIFFWarningExt(thandle_t fd, const char* module, const char* fmt, ...) } +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/src/libs/tiff/tif_write.c b/src/libs/tiff/tif_write.c index ec371361e0..bd084181d0 100644 --- a/src/libs/tiff/tif_write.c +++ b/src/libs/tiff/tif_write.c @@ -1,4 +1,4 @@ -/* $Id: tif_write.c,v 1.22.2.4 2009-08-28 02:23:19 bfriesen Exp $ */ +/* $Id: tif_write.c,v 1.22.2.5 2010-06-08 18:50:43 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -709,3 +709,10 @@ TIFFSetWriteOffset(TIFF* tif, toff_t off) } /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/src/libs/tiff/tif_zip.c b/src/libs/tiff/tif_zip.c index 38a5773891..15091f8daa 100644 --- a/src/libs/tiff/tif_zip.c +++ b/src/libs/tiff/tif_zip.c @@ -1,4 +1,4 @@ -/* $Id: tif_zip.c,v 1.11.2.3 2007/11/22 21:24:51 fwarmerdam Exp $ */ +/* $Id: tif_zip.c,v 1.11.2.4 2010-06-08 18:50:43 bfriesen Exp $ */ /* * Copyright (c) 1995-1997 Sam Leffler @@ -410,3 +410,10 @@ bad: #endif /* ZIP_SUPORT */ /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/src/libs/tiff/tiffio.hxx b/src/libs/tiff/tiffio.hxx index ac7b9f2cd1..ee3fd32c74 100644 --- a/src/libs/tiff/tiffio.hxx +++ b/src/libs/tiff/tiffio.hxx @@ -1,4 +1,4 @@ -/* $Id: tiffio.hxx,v 1.1 2004/11/21 16:12:08 dron Exp $ */ +/* $Id: tiffio.hxx,v 1.1.2.1 2010-06-08 18:50:43 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -40,3 +40,10 @@ extern TIFF* TIFFStreamOpen(const char*, std::istream *); #endif /* _TIFFIO_HXX_ */ /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c++ + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/src/libs/tiff/tiffiop.h b/src/libs/tiff/tiffiop.h index 4faa5ef5c3..eb927f0572 100644 --- a/src/libs/tiff/tiffiop.h +++ b/src/libs/tiff/tiffiop.h @@ -1,4 +1,4 @@ -/* $Id: tiffiop.h,v 1.51.2.1 2009-01-06 19:08:09 bfriesen Exp $ */ +/* $Id: tiffiop.h,v 1.51.2.6 2010-06-12 02:55:16 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -238,10 +238,15 @@ struct tiff { #endif /* NB: the uint32 casts are to silence certain ANSI-C compilers */ -#define TIFFhowmany(x, y) ((((uint32)(x))+(((uint32)(y))-1))/((uint32)(y))) +#define TIFFhowmany(x, y) (((uint32)x < (0xffffffff - (uint32)(y-1))) ? \ + ((((uint32)(x))+(((uint32)(y))-1))/((uint32)(y))) : \ + 0U) #define TIFFhowmany8(x) (((x)&0x07)?((uint32)(x)>>3)+1:(uint32)(x)>>3) #define TIFFroundup(x, y) (TIFFhowmany(x,y)*(y)) +/* Safe multiply which returns zero if there is an integer overflow */ +#define TIFFSafeMultiply(t,v,m) ((((t)m != (t)0) && (((t)((v*m)/m)) == (t)v)) ? (t)(v*m) : (t)0) + #define TIFFmax(A,B) ((A)>(B)?(A):(B)) #define TIFFmin(A,B) ((A)<(B)?(A):(B)) @@ -338,3 +343,10 @@ extern TIFFCodec _TIFFBuiltinCODECS[]; #endif /* _TIFFIOP_ */ /* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/src/libs/tiff/uvcode.h b/src/libs/tiff/uvcode.h index 5b2d7d71fa..50f11d7e0a 100644 --- a/src/libs/tiff/uvcode.h +++ b/src/libs/tiff/uvcode.h @@ -171,3 +171,10 @@ static struct { { (float)0.016994, 31, 16237 }, { (float)0.023659, 21, 16268 }, }; +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */