From 5f64fb1daace83ebd075dafb3bd634b426c9a69b Mon Sep 17 00:00:00 2001 From: Takatsugu Nokubi Date: Thu, 1 Aug 2019 14:59:58 +0900 Subject: [PATCH] add limitation to width and height --- include/sixel.h.in | 3 +++ src/decoder.c | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/include/sixel.h.in b/include/sixel.h.in index 7ffe90fa..4365c670 100644 --- a/include/sixel.h.in +++ b/include/sixel.h.in @@ -366,6 +366,9 @@ typedef int SIXELSTATUS; #define SIXEL_OPTFLAG_VERSION ('V') /* -V, --version: show version and license info */ #define SIXEL_OPTFLAG_HELP ('H') /* -H, --help: show this help */ +#define SIXEL_WIDTH_LIMIT 1000000 +#define SIXEL_HEIGHT_LIMIT 1000000 + #if SIXEL_USE_DEPRECATED_SYMBOLS /* output character size */ enum characterSize { diff --git a/src/decoder.c b/src/decoder.c index 63ab4aff..c763e4d3 100644 --- a/src/decoder.c +++ b/src/decoder.c @@ -315,6 +315,11 @@ sixel_decoder_decode( goto end; } + if (sx > SIXEL_WIDTH_LIMIT || sy > SIXEL_HEIGHT_LIMIT) { + status = SIXEL_BAD_INPUT; + goto end; + } + status = sixel_helper_write_image_file(indexed_pixels, sx, sy, palette, SIXEL_PIXELFORMAT_PAL8, decoder->output,