terminal: fix out-of-bounds access in CSI W handler with no params

CSI ? W (cursor tabulation control) accessed input.params[0] without
first checking that params.len > 0, causing an index out-of-bounds
panic when the sequence had an intermediate but no parameters.

Add a params.len == 1 guard before accessing params[0].

Found by AFL++ fuzzing.
This commit is contained in:
Mitchell Hashimoto
2026-03-01 14:21:48 -08:00
parent 72df30f14b
commit dcaa8f3979
2 changed files with 20 additions and 1 deletions

View File

@@ -1188,7 +1188,10 @@ pub fn Stream(comptime Handler: type) type {
return;
},
1 => if (input.intermediates[0] == '?' and input.params[0] == 5) {
1 => if (input.intermediates[0] == '?' and
input.params.len == 1 and
input.params[0] == 5)
{
try self.handler.vt(.tab_reset, {});
} else log.warn("invalid cursor tabulation control: {f}", .{input}),