allow huge png metadata chunks

By default, libpng refuses to open files with a metadata chunk larger than
8mb. Disable this sanity check.

See: https://github.com/lovell/sharp/issues/1664
This commit is contained in:
John Cupitt 2019-04-20 05:54:37 +01:00
parent 5301df3d6b
commit 8d7e03237a
1 changed files with 7 additions and 0 deletions

View File

@ -71,6 +71,8 @@
* - support png8 palette write with palette, colours, Q, dither
* 25/8/18
* - support xmp read/write
* 20/4/19
* - allow huge metadata
*/
/*
@ -260,8 +262,13 @@ read_new_filename( VipsImage *out, const char *name, gboolean fail )
/* Read enough of the file that png_get_interlace_type() will start
* working.
*
* By default, libpng refuses to open files with a metadata chunk
* larger than 8mb. png_set_chunk_malloc_max() disables this sanity
* check.
*/
png_init_io( read->pPng, read->fp );
png_set_chunk_malloc_max( read->pPng, 0 );
png_read_info( read->pPng, read->pInfo );
return( read );