1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
From: NOKUBI Takatsugu <knok@daionet.gr.jp>
Date: Tue, 20 Aug 2019 15:20:55 +0900
Subject: 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 397974f..8552c23 100644
--- a/include/sixel.h.in
+++ b/include/sixel.h.in
@@ -355,6 +355,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 98b5c30..e3fbd0d 100644
--- a/src/decoder.c
+++ b/src/decoder.c
@@ -303,6 +303,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,
|