aboutsummaryrefslogtreecommitdiffstats
path: root/src/kdl.c
diff options
context:
space:
mode:
authoruser <user@clank>2026-08-19 22:48:31 +0200
committeruser <user@clank>2026-08-19 22:48:31 +0200
commit009350acbcd4360680b8fa228d8cd03a2f2b5e93 (patch)
treeef0eadb14cc8186829c4b7ce46955ea88443a405 /src/kdl.c
parentwebdemo: the theme symlink is a dependency of the image (diff)
downloadslosh-009350acbcd4360680b8fa228d8cd03a2f2b5e93.tar.gz
slosh-009350acbcd4360680b8fa228d8cd03a2f2b5e93.tar.xz
slosh-009350acbcd4360680b8fa228d8cd03a2f2b5e93.zip
parsers: fix seven bugs found by fuzzing
kdl: heap-buffer-overflow on trailing backslash in a string (a"\) jsonval: heap-buffer-overflow on truncated \uXXXX escape ("\u) jsonval: UB float-to-long cast on out-of-range numbers (2e22) expr: UB signed overflow in arithmetic ops — wrap as uint32 expr: INT32_MIN / -1 SIGFPE guard in OP_DIV/OP_MOD expr: stack overflow on deep nesting — add MAX_DEPTH 256 expr: 64-bit + saturation in OP_DIST to prevent squared overflow input: NULL memcpy in input_timeout's re-parse path input: signed overflow in CSI and SGR mouse parameter accumulation
Diffstat (limited to 'src/kdl.c')
-rw-r--r--src/kdl.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/kdl.c b/src/kdl.c
index 13d624f..41f9768 100644
--- a/src/kdl.c
+++ b/src/kdl.c
@@ -83,7 +83,12 @@ static char *parse_string(K *k) {
while (*k->p && *k->p != '"') {
char c = *k->p++;
if (c == '\\') {
- char e = *k->p++;
+ /* A backslash as the last byte must not step past the terminator:
+ * consuming the NUL would leave the loop reading out of bounds. Break
+ * and let the unterminated-string check below report it. */
+ char e = *k->p;
+ if (!e) break;
+ k->p++;
switch (e) {
case 'n': c = '\n'; break;
case 't': c = '\t'; break;