From 211007cfbe7c6c923ca4f1c99dc239998e64b6c7 Mon Sep 17 00:00:00 2001 From: Tommi Hirvola Date: Mon, 4 Mar 2024 12:56:30 +0200 Subject: set upper limit for REP escape sequence argument Previously, printf 'L\033[2147483647b' would call tputc('L') 2^31 times, making st unresponsive. This commit allows repeating the last character at most 65535 times in order to prevent freezing and DoS attacks. --- st.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'st.c') diff --git a/st.c b/st.c index dd82d37..61799a7 100644 --- a/st.c +++ b/st.c @@ -1705,7 +1705,7 @@ csihandle(void) ttywrite(vtiden, strlen(vtiden), 0); break; case 'b': /* REP -- if last char is printable print it more times */ - DEFAULT(csiescseq.arg[0], 1); + LIMIT(csiescseq.arg[0], 1, 65535); if (term.lastc) while (csiescseq.arg[0]-- > 0) tputc(term.lastc); -- cgit v1.2.3