From 15416c410db6afee0cbbe02a47de7fe7a5de0238 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Mon, 13 Sep 2021 14:40:20 +0100 Subject: [PATCH] raise the PNG text chunk limit Raise the PNG text chunk limit to 50, since it seems some real images have a text chunk per line of exif data. See https://github.com/libvips/libvips/issues/2433 --- libvips/foreign/pforeign.h | 4 +++- libvips/foreign/vipspng.c | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/libvips/foreign/pforeign.h b/libvips/foreign/pforeign.h index 8633be92..5e03fad4 100644 --- a/libvips/foreign/pforeign.h +++ b/libvips/foreign/pforeign.h @@ -45,7 +45,9 @@ extern "C" { ) #endif /*HAVE_CHECKED_MUL*/ -#define MAX_PNG_TEXT_CHUNKS 20 +/* We've seen real images with 28 chunks, so set 50. + */ +#define MAX_PNG_TEXT_CHUNKS 50 void vips__tiff_init( void ); diff --git a/libvips/foreign/vipspng.c b/libvips/foreign/vipspng.c index 2510a6e9..1123c95a 100644 --- a/libvips/foreign/vipspng.c +++ b/libvips/foreign/vipspng.c @@ -570,7 +570,8 @@ png2vips_header( Read *read, VipsImage *out ) if( !read->unlimited && num_text > MAX_PNG_TEXT_CHUNKS ) { vips_error( "vipspng", - "%s", _( "too many text chunks" ) ); + _( "%d text chunks, image blocked" ), + num_text ); return( -1 ); }