Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(382)

Unified Diff: third_party/libtiff/tif_read.c

Issue 1563103002: XFA: Upgrade to libtiff 4.0.6. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: rename to libtiff Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/libtiff/tif_print.c ('k') | third_party/libtiff/tif_strip.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/libtiff/tif_read.c
diff --git a/third_party/tiff_v403/tif_read.c b/third_party/libtiff/tif_read.c
similarity index 95%
rename from third_party/tiff_v403/tif_read.c
rename to third_party/libtiff/tif_read.c
index eb9350846e514969d69ecbed03efaebdc0f675dd..5cb419bd41660a515e5a2762b28124c497c9d3b9 100644
--- a/third_party/tiff_v403/tif_read.c
+++ b/third_party/libtiff/tif_read.c
@@ -1,4 +1,4 @@
-/* $Id: tif_read.c,v 1.41 2012-07-06 19:22:58 bfriesen Exp $ */
+/* $Id: tif_read.c,v 1.45 2015-06-07 22:35:40 bfriesen Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@@ -47,7 +47,7 @@ TIFFFillStripPartial( TIFF *tif, int strip, tmsize_t read_ahead, int restart )
{
static const char module[] = "TIFFFillStripPartial";
register TIFFDirectory *td = &tif->tif_dir;
- uint64 unused_data;
+ tmsize_t unused_data;
uint64 read_offset;
tmsize_t cc, to_read;
/* tmsize_t bytecountm; */
@@ -94,7 +94,7 @@ TIFFFillStripPartial( TIFF *tif, int strip, tmsize_t read_ahead, int restart )
if( unused_data > 0 )
{
assert((tif->tif_flags&TIFF_BUFFERMMAP)==0);
- memmove( tif->tif_rawdata, tif->tif_rawcp, (size_t)unused_data );
+ memmove( tif->tif_rawdata, tif->tif_rawcp, unused_data );
}
/*
@@ -113,12 +113,12 @@ TIFFFillStripPartial( TIFF *tif, int strip, tmsize_t read_ahead, int restart )
/*
** How much do we want to read?
*/
- to_read = (tmsize_t)(tif->tif_rawdatasize - unused_data);
+ to_read = tif->tif_rawdatasize - unused_data;
if( (uint64) to_read > td->td_stripbytecount[strip]
- tif->tif_rawdataoff - tif->tif_rawdataloaded )
{
- to_read = (tmsize_t)(td->td_stripbytecount[strip]
- - tif->tif_rawdataoff - tif->tif_rawdataloaded);
+ to_read = (tmsize_t) td->td_stripbytecount[strip]
+ - tif->tif_rawdataoff - tif->tif_rawdataloaded;
}
assert((tif->tif_flags&TIFF_BUFFERMMAP)==0);
@@ -141,8 +141,8 @@ TIFFFillStripPartial( TIFF *tif, int strip, tmsize_t read_ahead, int restart )
return 0;
}
- tif->tif_rawdataoff = (tmsize_t)(tif->tif_rawdataoff + tif->tif_rawdataloaded - unused_data) ;
- tif->tif_rawdataloaded = (tmsize_t)unused_data + to_read;
+ tif->tif_rawdataoff = tif->tif_rawdataoff + tif->tif_rawdataloaded - unused_data ;
+ tif->tif_rawdataloaded = unused_data + to_read;
tif->tif_rawcp = tif->tif_rawdata;
@@ -321,7 +321,7 @@ TIFFReadEncodedStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size)
uint32 rowsperstrip;
uint32 stripsperplane;
uint32 stripinplane;
- uint16 plane, comp;
+ uint16 plane;
uint32 rows;
tmsize_t stripsize;
if (!TIFFCheckRead(tif,0))
@@ -352,42 +352,12 @@ TIFFReadEncodedStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size)
return((tmsize_t)(-1));
if ((size!=(tmsize_t)(-1))&&(size<stripsize))
stripsize=size;
-
- /*
- * discard those.
- * keep code modified by Changjin Gao.
- * Xiaochuan Liu 20100828.
- */
- /*if (!TIFFFillStrip(tif,strip))
+ if (!TIFFFillStrip(tif,strip))
return((tmsize_t)(-1));
if ((*tif->tif_decodestrip)(tif,buf,stripsize,plane)<=0)
return((tmsize_t)(-1));
(*tif->tif_postdecode)(tif,buf,stripsize);
- return(stripsize);*/
-
- /*
- * Changjin Gao 20110726 fixed decode error issue.
- * Test file: mantis #27308 020511-1158450.tiff.
- */
- comp = COMPRESSION_NONE;
-StripDecode:
- if (TIFFFillStrip(tif, strip) && (*tif->tif_decodestrip)(tif, buf, stripsize, plane) > 0)
- {
- (*tif->tif_postdecode)(tif, buf, stripsize);
- return (stripsize);
- }
- else
- {
- if (comp < 9)
- {
- TIFFSetField(tif, TIFFTAG_COMPRESSION, comp);
- TIFFSetField(tif, TIFFTAG_FAXMODE,FAXMODE_CLASSIC);
- comp++;
- goto StripDecode;
- }
-
- return ((tsize_t) -1);
- }
+ return(stripsize);
}
static tmsize_t
@@ -488,7 +458,7 @@ TIFFReadRawStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size)
return ((tmsize_t)(-1));
}
bytecount = td->td_stripbytecount[strip];
- if (bytecount <= 0) {
+ if ((int64)bytecount <= 0) {
#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
TIFFErrorExt(tif->tif_clientdata, module,
"%I64u: Invalid strip byte count, strip %lu",
@@ -528,7 +498,7 @@ TIFFFillStrip(TIFF* tif, uint32 strip)
if ((tif->tif_flags&TIFF_NOREADRAW)==0)
{
uint64 bytecount = td->td_stripbytecount[strip];
- if (bytecount <= 0) {
+ if ((int64)bytecount <= 0) {
#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
TIFFErrorExt(tif->tif_clientdata, module,
"Invalid strip byte count %I64u, strip %lu",
@@ -831,7 +801,7 @@ TIFFFillTile(TIFF* tif, uint32 tile)
if ((tif->tif_flags&TIFF_NOREADRAW)==0)
{
uint64 bytecount = td->td_stripbytecount[tile];
- if (bytecount <= 0) {
+ if ((int64)bytecount <= 0) {
#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
TIFFErrorExt(tif->tif_clientdata, module,
"%I64u: Invalid tile byte count, tile %lu",
@@ -960,8 +930,11 @@ TIFFReadBufferSetup(TIFF* tif, void* bp, tmsize_t size)
tif->tif_flags &= ~TIFF_MYBUFFER;
} else {
tif->tif_rawdatasize = (tmsize_t)TIFFroundup_64((uint64)size, 1024);
- if (tif->tif_rawdatasize==0)
- tif->tif_rawdatasize=(tmsize_t)(-1);
+ if (tif->tif_rawdatasize==0) {
+ TIFFErrorExt(tif->tif_clientdata, module,
+ "Invalid buffer size");
+ return (0);
+ }
tif->tif_rawdata = (uint8*) _TIFFmalloc(tif->tif_rawdatasize);
tif->tif_flags |= TIFF_MYBUFFER;
}
@@ -1017,10 +990,12 @@ TIFFStartStrip(TIFF* tif, uint32 strip)
static int
TIFFStartTile(TIFF* tif, uint32 tile)
{
+ static const char module[] = "TIFFStartTile";
TIFFDirectory *td = &tif->tif_dir;
+ uint32 howmany32;
- if (!_TIFFFillStriles( tif ) || !tif->tif_dir.td_stripbytecount)
- return 0;
+ if (!_TIFFFillStriles( tif ) || !tif->tif_dir.td_stripbytecount)
+ return 0;
if ((tif->tif_flags & TIFF_CODERSETUP) == 0) {
if (!(*tif->tif_setupdecode)(tif))
@@ -1028,12 +1003,18 @@ TIFFStartTile(TIFF* tif, uint32 tile)
tif->tif_flags |= TIFF_CODERSETUP;
}
tif->tif_curtile = tile;
- tif->tif_row =
- (tile % TIFFhowmany_32(td->td_imagewidth, td->td_tilewidth)) *
- td->td_tilelength;
- tif->tif_col =
- (tile % TIFFhowmany_32(td->td_imagelength, td->td_tilelength)) *
- td->td_tilewidth;
+ howmany32=TIFFhowmany_32(td->td_imagewidth, td->td_tilewidth);
+ if (howmany32 == 0) {
+ TIFFErrorExt(tif->tif_clientdata,module,"Zero tiles");
+ return 0;
+ }
+ tif->tif_row = (tile % howmany32) * td->td_tilelength;
+ howmany32=TIFFhowmany_32(td->td_imagelength, td->td_tilelength);
+ if (howmany32 == 0) {
+ TIFFErrorExt(tif->tif_clientdata,module,"Zero tiles");
+ return 0;
+ }
+ tif->tif_col = (tile % howmany32) * td->td_tilewidth;
tif->tif_flags &= ~TIFF_BUF4WRITE;
if (tif->tif_flags&TIFF_NOREADRAW)
{
@@ -1111,4 +1092,3 @@ _TIFFSwab64BitData(TIFF* tif, uint8* buf, tmsize_t cc)
* fill-column: 78
* End:
*/
-
« no previous file with comments | « third_party/libtiff/tif_print.c ('k') | third_party/libtiff/tif_strip.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698