diff options
| author | Tommi Hirvola <tommi@hirvola.fi> | 2024-03-04 12:56:30 +0200 |
|---|---|---|
| committer | Hiltjo Posthuma <hiltjo@codemadness.org> | 2024-03-04 23:50:58 +0100 |
| commit | 95f22c53059ccd60ee701ccf2659dacd95e4e89a (patch) | |
| tree | 5aa7ce5934a04364062d6b5151a949c4483dc75e | |
| parent | Fix cursor move with wide glyphs (diff) | |
| download | st-95f22c53059ccd60ee701ccf2659dacd95e4e89a.tar.gz st-95f22c53059ccd60ee701ccf2659dacd95e4e89a.zip | |
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.
| -rw-r--r-- | st.c | 2 |
1 files changed, 1 insertions, 1 deletions
| @@ -1643,7 +1643,7 @@ csihandle(void) | |||
| 1643 | ttywrite(vtiden, strlen(vtiden), 0); | 1643 | ttywrite(vtiden, strlen(vtiden), 0); |
| 1644 | break; | 1644 | break; |
| 1645 | case 'b': /* REP -- if last char is printable print it <n> more times */ | 1645 | case 'b': /* REP -- if last char is printable print it <n> more times */ |
| 1646 | DEFAULT(csiescseq.arg[0], 1); | 1646 | LIMIT(csiescseq.arg[0], 1, 65535); |
| 1647 | if (term.lastc) | 1647 | if (term.lastc) |
| 1648 | while (csiescseq.arg[0]-- > 0) | 1648 | while (csiescseq.arg[0]-- > 0) |
| 1649 | tputc(term.lastc); | 1649 | tputc(term.lastc); |
