refactor(tui): check for out of bound access after snprintf (#24751)

Counterintuitively, snprintf returns the number of characters it _should
have written_ if it had not encoutered the length bound, thus leading to
a potential buffer overflow.

Co-authored-by: zeertzjq <zeertzjq@outlook.com>
This commit is contained in:
Thomas Vigouroux 2023-08-19 02:19:36 +02:00 committed by GitHub
parent 5a6c7c805b
commit 7a3fef9e34
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -297,10 +297,10 @@ static void forward_simple_utf8(TermInput *input, TermKeyKey *key)
} else {
buf[len++] = *ptr;
}
assert(len < sizeof(buf));
ptr++;
}
assert(len < sizeof(buf));
tinput_enqueue(input, buf, len);
}