Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
8 changes: 7 additions & 1 deletion libvips/foreign/gifload.c
Original file line number Diff line number Diff line change
Expand Up @@ -700,8 +700,14 @@ vips_foreign_load_gif_scan_extension( VipsForeignLoadGif *gif )
static int
vips_foreign_load_gif_set_header( VipsForeignLoadGif *gif, VipsImage *image )
{
const gint64 total_height = (gint64) gif->file->SHeight * gif->n;
if ( total_height <= 0 || total_height > VIPS_MAX_COORD ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could probably still get int overflow here. How about doing the multiplication as gint64? That would be safe.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to cast one of the args to the * as well, or the mult will be done as int :(

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I've updated this, plus added an appropriate message to the error log.

vips_error( "gifload", "%s",
_( "image size out of bounds" ) );
return( -1 );
}
vips_image_init_fields( image,
gif->file->SWidth, gif->file->SHeight * gif->n,
gif->file->SWidth, (int) total_height,
(gif->has_colour ? 3 : 1) + (gif->has_transparency ? 1 : 0),
VIPS_FORMAT_UCHAR, VIPS_CODING_NONE,
gif->has_colour ?
Expand Down