From f9f8686c7d1853c4b416bda06edb7816f9c9c9a9 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sat, 17 Dec 2016 22:33:11 +0000 Subject: [PATCH] * 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. --- ChangeLog | 6 ++++++ libtiff/tif_getimage.c | 20 +++++++++++++++++--- libtiff/tiffio.h | 4 +++- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 82b2580e..5d459728 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2016-12-17 Even Rouault + + * 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 * tools/tiff2ps.c: fix 2 heap-based buffer overflows (in PSDataBW diff --git a/libtiff/tif_getimage.c b/libtiff/tif_getimage.c index f41e9e08..c0eb6df0 100644 --- a/libtiff/tif_getimage.c +++ b/libtiff/tif_getimage.c @@ -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 @@ -2815,6 +2815,13 @@ BuildMapBitdepth16To8(TIFFRGBAImage* img) int 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] = ""; TIFFRGBAImage img; @@ -2836,7 +2843,7 @@ TIFFReadRGBAStrip(TIFF* tif, uint32 row, uint32 * raster ) 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.col_offset = 0; @@ -2866,6 +2873,13 @@ TIFFReadRGBAStrip(TIFF* tif, uint32 row, uint32 * raster ) int 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] = ""; TIFFRGBAImage img; @@ -2901,7 +2915,7 @@ TIFFReadRGBATile(TIFF* tif, uint32 col, uint32 row, uint32 * raster) */ if (!TIFFRGBAImageOK(tif, emsg) - || !TIFFRGBAImageBegin(&img, tif, 0, emsg)) { + || !TIFFRGBAImageBegin(&img, tif, stop_on_error, emsg)) { TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "%s", emsg); return( 0 ); } diff --git a/libtiff/tiffio.h b/libtiff/tiffio.h index 6a84d803..6e508181 100644 --- a/libtiff/tiffio.h +++ b/libtiff/tiffio.h @@ -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 @@ -430,6 +430,8 @@ extern int TIFFReadRGBAImageOriented(TIFF*, uint32, uint32, uint32*, int, int); extern int TIFFReadRGBAStrip(TIFF*, 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 TIFFRGBAImageBegin(TIFFRGBAImage*, TIFF*, int, char [1024]); extern int TIFFRGBAImageGet(TIFFRGBAImage*, uint32*, uint32, uint32);