jcs
/subtext
/amendments
/369
ansi: Bound sscanf char assignment
jcs made amendment 369 about 1 year ago
--- ansi.c Wed Mar 1 16:41:13 2023
+++ ansi.c Tue Mar 7 22:26:04 2023
@@ -53,8 +53,9 @@ ansi(struct session *s, ...)
char ansi_tmp[10];
char *ansi_out;
va_list ap;
- short attr, val, val2, len, n;
-
+ short attr, val, val2, n;
+ size_t len;
+
ansi_out = (char *)&ansi_buf[last_ansi_buf];
if (++last_ansi_buf >= nitems(ansi_buf))
last_ansi_buf = 0;
@@ -227,7 +228,6 @@ ansi(struct session *s, ...)
size_t
ansi_strip(char *inp, char **outp)
{
- char *ret;
size_t ilen = strlen(inp);
size_t n, olen = 0;
short in_csi;
@@ -296,7 +296,7 @@ ansi_probe_screen_size(struct session *s)
/* \e[12;34R */
if (s->ibuf[0] == ESC && s->ibuf[1] == '[' &&
- sscanf((char *)&s->ibuf + 2, "%d;%d%[R]", &rows, &cols, &c) == 3 &&
+ sscanf((char *)&s->ibuf + 2, "%d;%d%1[R]", &rows, &cols, &c) == 3 &&
c[0] == 'R') {
if (cols >= MIN_TERMINAL_COLUMNS && rows >= MIN_TERMINAL_LINES) {
s->terminal_columns = cols;