File: 0003-add-limitation-to-width-and-height.patch

package info (click to toggle)
libsixel 1.8.6-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 13,632 kB
  • sloc: ansic: 23,497; sh: 8,443; cpp: 1,227; python: 526; makefile: 444; xml: 271; ruby: 31; perl: 26
file content (39 lines) | stat: -rw-r--r-- 1,297 bytes parent folder | download | duplicates (4)
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: Takatsugu Nokubi <takatsugu.nokubi@robotfund.co.jp>
Date: Thu, 1 Aug 2019 14:59:58 +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 7ffe90f..4365c67 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 63ab4af..c763e4d 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,