From 451cfcd28282b687d8223569404f105e74fc979e Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Sun, 29 Aug 2021 19:08:51 +0100 Subject: [PATCH] small cleanups from "unlimited" option --- ChangeLog | 1 + libvips/foreign/pngload.c | 5 ++++- libvips/foreign/spngload.c | 8 ++++++-- libvips/foreign/vipspng.c | 14 ++++++++++---- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 580bfb98..2d4aac5a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,6 @@ 16/8/21 started 8.11.4 - fix off-by-one error in new rank fast path +- add "unlimited" flag to png load [joshuamsager] 14/7/21 started 8.11.3 - build threadpool later [kleisauke] diff --git a/libvips/foreign/pngload.c b/libvips/foreign/pngload.c index 34340e91..1687cbc4 100644 --- a/libvips/foreign/pngload.c +++ b/libvips/foreign/pngload.c @@ -2,6 +2,8 @@ * * 5/12/11 * - from tiffload.c + * 29/8/21 joshuamsager + * - add "unlimited" flag to png load */ /* @@ -133,7 +135,8 @@ vips_foreign_load_png_load( VipsForeignLoad *load ) { VipsForeignLoadPng *png = (VipsForeignLoadPng *) load; - if( vips__png_read_source( png->source, load->real, load->fail, png->unlimited ) ) + if( vips__png_read_source( png->source, load->real, + load->fail, png->unlimited ) ) return( -1 ); return( 0 ); diff --git a/libvips/foreign/spngload.c b/libvips/foreign/spngload.c index 924ab8ed..a8676a28 100644 --- a/libvips/foreign/spngload.c +++ b/libvips/foreign/spngload.c @@ -4,6 +4,8 @@ * - from pngload.c * 19/2/21 781545872 * - read out background, if we can + * 29/8/21 joshuamsager + * - add "unlimited" flag to png load */ /* @@ -354,8 +356,10 @@ vips_foreign_load_png_header( VipsForeignLoad *load ) * they wish. */ if ( !png->unlimited ) { - spng_set_image_limits( png->ctx, VIPS_MAX_COORD, VIPS_MAX_COORD ); - spng_set_chunk_limits( png->ctx, 60 * 1024 * 1024, 60 * 1024 * 1024 ); + spng_set_image_limits( png->ctx, + VIPS_MAX_COORD, VIPS_MAX_COORD ); + spng_set_chunk_limits( png->ctx, + 60 * 1024 * 1024, 60 * 1024 * 1024 ); } if( vips_source_rewind( png->source ) ) diff --git a/libvips/foreign/vipspng.c b/libvips/foreign/vipspng.c index cd0ea45a..2510a6e9 100644 --- a/libvips/foreign/vipspng.c +++ b/libvips/foreign/vipspng.c @@ -81,6 +81,8 @@ * - only warn for saving bad profiles, don't fail * 19/2/21 781545872 * - read out background, if we can + * 29/8/21 joshuamsager + * - add "unlimited" flag to png load */ /* @@ -256,7 +258,8 @@ vips_png_read_source( png_structp pPng, png_bytep data, png_size_t length ) } static Read * -read_new( VipsSource *source, VipsImage *out, gboolean fail, gboolean unlimited ) +read_new( VipsSource *source, VipsImage *out, + gboolean fail, gboolean unlimited ) { Read *read; @@ -564,7 +567,8 @@ png2vips_header( Read *read, VipsImage *out ) /* Very large numbers of text chunks are used in DoS * attacks. */ - if( !read->unlimited && num_text > MAX_PNG_TEXT_CHUNKS ) { + if( !read->unlimited && + num_text > MAX_PNG_TEXT_CHUNKS ) { vips_error( "vipspng", "%s", _( "too many text chunks" ) ); return( -1 ); @@ -778,7 +782,8 @@ vips__png_ispng_source( VipsSource *source ) } int -vips__png_header_source( VipsSource *source, VipsImage *out, gboolean unlimited ) +vips__png_header_source( VipsSource *source, VipsImage *out, + gboolean unlimited ) { Read *read; @@ -795,7 +800,8 @@ vips__png_header_source( VipsSource *source, VipsImage *out, gboolean unlimited } int -vips__png_read_source( VipsSource *source, VipsImage *out, gboolean fail, gboolean unlimited ) +vips__png_read_source( VipsSource *source, VipsImage *out, + gboolean fail, gboolean unlimited ) { Read *read;