From 5df65ec6fdd5a5367dd6e1e274d6018a4d40904f Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Fri, 19 May 2017 16:07:36 +0100 Subject: [PATCH] fix tiff read with page > 0 could break edge tiles under some circumstances --- ChangeLog | 3 +++ configure.ac | 6 +++--- libvips/foreign/tiff2vips.c | 19 +++++++++++++------ 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index b9db7479..74587bcf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +19/5/17 started 8.5.6 +- tiff read with start page > 0 could break edge tiles or strips + 23/4/17 started 8.5.5 - doc polishing - more improvements for truncated PNG files, thanks juyunsang diff --git a/configure.ac b/configure.ac index 2bce35fc..10cf847a 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # also update the version number in the m4 macros below -AC_INIT([vips], [8.5.5], [vipsip@jiscmail.ac.uk]) +AC_INIT([vips], [8.5.6], [vipsip@jiscmail.ac.uk]) # required for gobject-introspection AC_PREREQ(2.62) @@ -18,7 +18,7 @@ AC_CONFIG_MACRO_DIR([m4]) # user-visible library versioning m4_define([vips_major_version], [8]) m4_define([vips_minor_version], [5]) -m4_define([vips_micro_version], [5]) +m4_define([vips_micro_version], [6]) m4_define([vips_version], [vips_major_version.vips_minor_version.vips_micro_version]) @@ -38,7 +38,7 @@ VIPS_VERSION_STRING=$VIPS_VERSION-`date` # binary interface changes not backwards compatible?: reset age to 0 LIBRARY_CURRENT=49 -LIBRARY_REVISION=4 +LIBRARY_REVISION=5 LIBRARY_AGE=7 # patched into include/vips/version.h diff --git a/libvips/foreign/tiff2vips.c b/libvips/foreign/tiff2vips.c index 87b187d9..7dffcb0b 100644 --- a/libvips/foreign/tiff2vips.c +++ b/libvips/foreign/tiff2vips.c @@ -173,6 +173,8 @@ * - invalidate operation on read error * 27/1/17 * - if rows_per_strip is large, read with scanline API instead + * 19/5/17 + * - page > 0 could break edge tiles or strips */ /* @@ -1469,8 +1471,11 @@ rtiff_fill_region( VipsRegion *out, void *seq, void *a, void *b, gboolean *stop x = 0; while( x < r->width ) { - int page_no = rtiff->page + (r->top + y) / - rtiff->header.height; + /* page_no is within this toilet roll image, not tiff + * file page number ... add the number of the start + * page to get that. + */ + int page_no = (r->top + y) / rtiff->header.height; int page_y = (r->top + y) % rtiff->header.height; /* Coordinate of the tile on this page that xy falls in. @@ -1478,7 +1483,7 @@ rtiff_fill_region( VipsRegion *out, void *seq, void *a, void *b, gboolean *stop int xs = ((r->left + x) / tile_width) * tile_width; int ys = (page_y / tile_height) * tile_height; - if( rtiff_set_page( rtiff, page_no ) || + if( rtiff_set_page( rtiff, rtiff->page + page_no ) || rtiff_read_tile( rtiff, buf, xs, ys ) ) { VIPS_GATE_STOP( "rtiff_fill_region: work" ); return( -1 ); @@ -1744,9 +1749,11 @@ rtiff_stripwise_generate( VipsRegion *or, y = 0; while( y < r->height ) { - /* Page number, position within this page. + /* page_no is within this toilet roll image, not tiff + * file page number ... add the number of the start + * page to get that. */ - int page_no = rtiff->page + (r->top + y) / page_height; + int page_no = (r->top + y) / page_height; int y_page = (r->top + y) % page_height; /* Strip number. @@ -1785,7 +1792,7 @@ rtiff_stripwise_generate( VipsRegion *or, g_assert( hit.height > 0 ); - if( rtiff_set_page( rtiff, page_no ) ) { + if( rtiff_set_page( rtiff, rtiff->page + page_no ) ) { VIPS_GATE_STOP( "rtiff_stripwise_generate: work" ); return( -1 ); }