From 197a21ed0e92d4f9fbc6c487c1f5a3803dd9d1d3 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Mon, 20 Feb 2017 22:36:35 +0000 Subject: [PATCH] don't load 0 length profiles some tiffs have 0 length icc profiles ... test profile length before we try to load it see https://github.com/jcupitt/libvips/issues/605 --- libvips/foreign/tiff2vips.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/libvips/foreign/tiff2vips.c b/libvips/foreign/tiff2vips.c index 6d5a0341..7dd9dddd 100644 --- a/libvips/foreign/tiff2vips.c +++ b/libvips/foreign/tiff2vips.c @@ -203,8 +203,8 @@ */ /* -#define DEBUG */ +#define DEBUG #ifdef HAVE_CONFIG_H #include @@ -1253,7 +1253,9 @@ rtiff_set_header( Rtiff *rtiff, VipsImage *out ) /* Read any ICC profile. */ if( TIFFGetField( rtiff->tiff, - TIFFTAG_ICCPROFILE, &data_length, &data ) ) { + TIFFTAG_ICCPROFILE, &data_length, &data ) && + data && + data_length ) { void *data_copy; if( !(data_copy = vips_malloc( NULL, data_length )) ) @@ -1266,7 +1268,9 @@ rtiff_set_header( Rtiff *rtiff, VipsImage *out ) /* Read any XMP metadata. */ if( TIFFGetField( rtiff->tiff, - TIFFTAG_XMLPACKET, &data_length, &data ) ) { + TIFFTAG_XMLPACKET, &data_length, &data ) && + data && + data_length ) { void *data_copy; if( !(data_copy = vips_malloc( NULL, data_length )) ) @@ -1279,7 +1283,9 @@ rtiff_set_header( Rtiff *rtiff, VipsImage *out ) /* Read any IPCT metadata. */ if( TIFFGetField( rtiff->tiff, - TIFFTAG_RICHTIFFIPTC, &data_length, &data ) ) { + TIFFTAG_RICHTIFFIPTC, &data_length, &data ) && + data && + data_length ) { void *data_copy; /* For no very good reason, libtiff stores IPCT as an array of @@ -1297,7 +1303,9 @@ rtiff_set_header( Rtiff *rtiff, VipsImage *out ) /* Read any photoshop metadata. */ if( TIFFGetField( rtiff->tiff, - TIFFTAG_PHOTOSHOP, &data_length, &data ) ) { + TIFFTAG_PHOTOSHOP, &data_length, &data ) && + data && + data_length ) { void *data_copy; if( !(data_copy = vips_malloc( NULL, data_length )) )