set png chunk limit to 50mb

we did have it unlimited, which could perhaps leave us open to DOS
attacks
This commit is contained in:
John Cupitt 2019-04-20 10:29:24 +01:00
parent ee854d43c4
commit 8fbbfd752f
2 changed files with 9 additions and 3 deletions

View File

@ -1510,6 +1510,13 @@ rtiff_fill_region( VipsRegion *out,
int x, y, z;
printf( "VIPS_IMAGE_SIZEOF_PEL() = %zd\n",
VIPS_IMAGE_SIZEOF_PEL( out->im ) );
printf( "rtiff->header.tile_size = %zd\n", rtiff->header.tile_size );
printf( "tile_width = %d\n", tile_width );
printf( "tile_height = %d\n", tile_height );
printf( "memcpy = %d\n", rtiff->memcpy );
/* Special case: we are filling a single tile exactly sized to match
* the tiff tile and we have no repacking to do for this format.
*/

View File

@ -264,12 +264,11 @@ read_new_filename( VipsImage *out, const char *name, gboolean fail )
* working.
*
* By default, libpng refuses to open files with a metadata chunk
* larger than 8mb. png_set_chunk_malloc_max() disables this sanity
* check.
* larger than 8mb. We've seen real files with 20mb, so set 50mb.
*/
png_init_io( read->pPng, read->fp );
#ifdef HAVE_PNG_SET_CHUNK_MALLOC_MAX
png_set_chunk_malloc_max( read->pPng, 0 );
png_set_chunk_malloc_max( read->pPng, 50 * 1024 * 1024 );
#endif /*HAVE_PNG_SET_CHUNK_MALLOC_MAX*/
png_read_info( read->pPng, read->pInfo );