better support for very long PNG comment names

pngs can have names comments -- improve support for very long comments.
This commit is contained in:
John Cupitt 2019-08-02 05:40:40 +01:00
parent 5e77ab948b
commit 4ea50fe6f0
1 changed files with 3 additions and 2 deletions

View File

@ -970,12 +970,13 @@ write_png_comment( VipsImage *image,
if( vips_isprefix( "png-comment-", field ) ) {
const char *str;
int i;
char key[80];
char key[256];
if( vips_image_get_string( write->in, field, &str ) )
return( image );
if( sscanf( field, "png-comment-%d-%80s", &i, key ) != 2 ) {
if( strlen( field ) > 256 ||
sscanf( field, "png-comment-%d-%80s", &i, key ) != 2 ) {
vips_error( "vips2png",
"%s", _( "bad png comment key" ) );
return( image );