Skip to content

Commit 9324932

Browse files
committed
Return error for too large GIF-files
1 parent c3e4ccb commit 9324932

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/Image.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,14 @@ Image::loadGIFFromBuffer(uint8_t *buf, unsigned len) {
535535
width = gif->SWidth;
536536
height = gif->SHeight;
537537

538+
/* Cairo limit:
539+
* https://lists.cairographics.org/archives/cairo/2010-December/021422.html
540+
*/
541+
if (width > 32767 || height > 32767) {
542+
GIF_CLOSE_FILE(gif);
543+
return CAIRO_STATUS_INVALID_SIZE;
544+
}
545+
538546
uint8_t *data = (uint8_t *) malloc(width * height * 4);
539547
if (!data) {
540548
GIF_CLOSE_FILE(gif);

0 commit comments

Comments
 (0)