From e2c83fe4bdb471c1222f12dad149a233667182ef Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Tue, 29 Aug 2017 09:49:38 +0100 Subject: [PATCH] fix jpegload fail we were only failing on libjpeg errors, but libjpeg treats very serious things thaht we want to be able to catch (like truncated files) as warnings ... we must therefore error out if fail is set and libjpeg issues a warning see https://github.com/lovell/sharp/issues/793 --- ChangeLog | 3 +++ configure.ac | 6 +++--- libvips/foreign/jpeg2vips.c | 25 +++++++++++++++++++++---- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index d764d9ca..875d3990 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +29/8/17 started 8.5.9 +- make --fail stop jpeg read on any libjpeg warning, thanks @mceachen + 2/8/17 started 8.5.8 - fix transparency detection in merge, thanks Haida - define env var VIPS_WARNING to hide warning messages diff --git a/configure.ac b/configure.ac index dbb76ee1..93e3ca5a 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.8], [vipsip@jiscmail.ac.uk]) +AC_INIT([vips], [8.5.9], [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], [8]) +m4_define([vips_micro_version], [9]) 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=7 +LIBRARY_REVISION=8 LIBRARY_AGE=7 # patched into include/vips/version.h diff --git a/libvips/foreign/jpeg2vips.c b/libvips/foreign/jpeg2vips.c index fb9b7c39..c06cb5cc 100644 --- a/libvips/foreign/jpeg2vips.c +++ b/libvips/foreign/jpeg2vips.c @@ -87,6 +87,10 @@ * - invalidate operation on read error * 12/5/17 * - fail aborts on error, not warning + * 29/8/17 + * - revert previous warning change: libvips reports serious corruption, + * like a truncated file, as a warning and we need to be able to catch + * that */ /* @@ -150,7 +154,7 @@ typedef struct _ReadJpeg { */ int shrink; - /* Fail on errors. + /* Fail on warning. */ gboolean fail; @@ -571,10 +575,23 @@ read_jpeg_generate( VipsRegion *or, printf( "read_jpeg_generate: lonjmp() exit\n" ); #endif /*DEBUG*/ - if( jpeg->fail ) - return( -1 ); + return( -1 ); + } - return( 0 ); + /* If --fail is set, we make read fail on any warnings. This + * will stop on any errors from the previous jpeg_read_scanlines(). + * libjpeg warnings are used for serious image corruption, like + * truncated files. + */ + if( jpeg->eman.pub.num_warnings > 0 && + jpeg->fail ) { + VIPS_GATE_STOP( "read_jpeg_generate: work" ); + + /* Only fail once. + */ + jpeg->eman.pub.num_warnings = 0; + + return( -1 ); } for( y = 0; y < r->height; y++ ) {