aboutsummaryrefslogtreecommitdiff
path: root/sixel.h
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2026-05-22 09:18:15 +0000
committerDaniel Eklöf <daniel@ekloef.se>2026-05-22 09:50:42 +0000
commit92187d2e4e1980b31ff2aa174d7f917d0945e175 (patch)
tree1d0991fb075c146de6feadc4b2d06e0e048f1aae /sixel.h
parentselection: do not copy empty text (diff)
sixel: clamp max width/height in 'CSI ? 2 ; 3 ; W ; H S'sixel-heap-buffer-overflow
This ensures the user cannot raise the maximum sixel size, where width*height cannot be represented as an integer. Note, we should consider moving all sixel width/height variables from int to size_t. But, since it doesn't make any sense with overly large sixel images, clamping the max width/height is enough. Add a static_assert() that checks SIXEL_MAX_WIDTH * SIXEL_MAX_HEIGHT doesn't overflow. Closes #2343
Diffstat (limited to 'sixel.h')
-rw-r--r--sixel.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/sixel.h b/sixel.h
index ab8a5050..5c18da1c 100644
--- a/sixel.h
+++ b/sixel.h
@@ -2,10 +2,14 @@
#include "terminal.h"
-#define SIXEL_MAX_COLORS 1024u
-#define SIXEL_MAX_WIDTH 10000u
+#define SIXEL_MAX_COLORS 1024u
+#define SIXEL_MAX_WIDTH 10000u
#define SIXEL_MAX_HEIGHT 10000u
+static_assert(SIXEL_MAX_WIDTH * SIXEL_MAX_HEIGHT ==
+ (size_t)SIXEL_MAX_WIDTH * SIXEL_MAX_HEIGHT,
+ "sixel max size triggers integer overflow");
+
typedef void (*sixel_put)(struct terminal *term, uint8_t c);
void sixel_fini(struct terminal *term);