* libtiff/tiffio.h, libtiff/tif_getimage.c: add TIFFReadRGBAStripExt()

and TIFFReadRGBATileExt() variants of the functions without ext, with
an extra argument to control the stop_on_error behaviour.
This commit is contained in:
Even Rouault 2016-12-17 22:33:11 +00:00
parent 0a85b00c8b
commit f9f8686c7d
3 changed files with 26 additions and 4 deletions

View File

@ -1,3 +1,9 @@
2016-12-17 Even Rouault <even.rouault at spatialys.com>
* libtiff/tiffio.h, libtiff/tif_getimage.c: add TIFFReadRGBAStripExt()
and TIFFReadRGBATileExt() variants of the functions without ext, with
an extra argument to control the stop_on_error behaviour.
2016-12-17 Even Rouault <even.rouault at spatialys.com> 2016-12-17 Even Rouault <even.rouault at spatialys.com>
* tools/tiff2ps.c: fix 2 heap-based buffer overflows (in PSDataBW * tools/tiff2ps.c: fix 2 heap-based buffer overflows (in PSDataBW

View File

@ -1,4 +1,4 @@
/* $Id: tif_getimage.c,v 1.99 2016-11-20 22:29:47 erouault Exp $ */ /* $Id: tif_getimage.c,v 1.100 2016-12-17 22:33:11 erouault Exp $ */
/* /*
* Copyright (c) 1991-1997 Sam Leffler * Copyright (c) 1991-1997 Sam Leffler
@ -2815,6 +2815,13 @@ BuildMapBitdepth16To8(TIFFRGBAImage* img)
int int
TIFFReadRGBAStrip(TIFF* tif, uint32 row, uint32 * raster ) TIFFReadRGBAStrip(TIFF* tif, uint32 row, uint32 * raster )
{
return TIFFReadRGBAStripExt(tif, row, raster, 0 );
}
int
TIFFReadRGBAStripExt(TIFF* tif, uint32 row, uint32 * raster, int stop_on_error)
{ {
char emsg[1024] = ""; char emsg[1024] = "";
TIFFRGBAImage img; TIFFRGBAImage img;
@ -2836,7 +2843,7 @@ TIFFReadRGBAStrip(TIFF* tif, uint32 row, uint32 * raster )
return (0); return (0);
} }
if (TIFFRGBAImageOK(tif, emsg) && TIFFRGBAImageBegin(&img, tif, 0, emsg)) { if (TIFFRGBAImageOK(tif, emsg) && TIFFRGBAImageBegin(&img, tif, stop_on_error, emsg)) {
img.row_offset = row; img.row_offset = row;
img.col_offset = 0; img.col_offset = 0;
@ -2866,6 +2873,13 @@ TIFFReadRGBAStrip(TIFF* tif, uint32 row, uint32 * raster )
int int
TIFFReadRGBATile(TIFF* tif, uint32 col, uint32 row, uint32 * raster) TIFFReadRGBATile(TIFF* tif, uint32 col, uint32 row, uint32 * raster)
{
return TIFFReadRGBATileExt(tif, col, row, raster, 0 );
}
int
TIFFReadRGBATileExt(TIFF* tif, uint32 col, uint32 row, uint32 * raster, int stop_on_error )
{ {
char emsg[1024] = ""; char emsg[1024] = "";
TIFFRGBAImage img; TIFFRGBAImage img;
@ -2901,7 +2915,7 @@ TIFFReadRGBATile(TIFF* tif, uint32 col, uint32 row, uint32 * raster)
*/ */
if (!TIFFRGBAImageOK(tif, emsg) if (!TIFFRGBAImageOK(tif, emsg)
|| !TIFFRGBAImageBegin(&img, tif, 0, emsg)) { || !TIFFRGBAImageBegin(&img, tif, stop_on_error, emsg)) {
TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "%s", emsg); TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "%s", emsg);
return( 0 ); return( 0 );
} }

View File

@ -1,4 +1,4 @@
/* $Id: tiffio.h,v 1.92 2016-01-23 21:20:34 erouault Exp $ */ /* $Id: tiffio.h,v 1.93 2016-12-17 22:33:11 erouault Exp $ */
/* /*
* Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1988-1997 Sam Leffler
@ -430,6 +430,8 @@ extern int TIFFReadRGBAImageOriented(TIFF*, uint32, uint32, uint32*, int, int);
extern int TIFFReadRGBAStrip(TIFF*, uint32, uint32 * ); extern int TIFFReadRGBAStrip(TIFF*, uint32, uint32 * );
extern int TIFFReadRGBATile(TIFF*, uint32, uint32, uint32 * ); extern int TIFFReadRGBATile(TIFF*, uint32, uint32, uint32 * );
extern int TIFFReadRGBAStripExt(TIFF*, uint32, uint32 *, int stop_on_error );
extern int TIFFReadRGBATileExt(TIFF*, uint32, uint32, uint32 *, int stop_on_error );
extern int TIFFRGBAImageOK(TIFF*, char [1024]); extern int TIFFRGBAImageOK(TIFF*, char [1024]);
extern int TIFFRGBAImageBegin(TIFFRGBAImage*, TIFF*, int, char [1024]); extern int TIFFRGBAImageBegin(TIFFRGBAImage*, TIFF*, int, char [1024]);
extern int TIFFRGBAImageGet(TIFFRGBAImage*, uint32*, uint32, uint32); extern int TIFFRGBAImageGet(TIFFRGBAImage*, uint32*, uint32, uint32);