Skip to content

Commit

Permalink
allow huge png metadata chunks
Browse files Browse the repository at this point in the history
By default, libpng refuses to open files with a metadata chunk larger than
8mb. Disable this sanity check.

See: lovell/sharp#1664
  • Loading branch information
jcupitt committed Apr 20, 2019
1 parent 5301df3 commit 8d7e032
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions libvips/foreign/vipspng.c
Expand Up @@ -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
*/

/*
Expand Down Expand Up @@ -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 );
Expand Down

0 comments on commit 8d7e032

Please sign in to comment.