win/tty: fix off-by-one NUL write in UTF-16 to WTF-8 conversion
Reserve one byte for the NUL terminator when passing the buffer size
to uv_utf16_to_wtf8() in the TTY line-read path. Without this, when
all input characters encode to exactly 3 UTF-8 bytes (e.g. CJK) and
the buffer size is divisible by 3, the NUL terminator is written one
byte past the allocated buffer.
The other two call sites in src/win/util.c already subtract 1 before
calling uv_utf16_to_wtf8(). This aligns tty.c with that convention.
Fixes: f3889085 ("win,tty: convert line-read UTF-16 to WTF-8")
Ref: GHSA-4prr-4742-3ccf
This commit is contained in:
parent
a19ceeb13a
commit
60e67eb7d7
@ -555,7 +555,7 @@ static DWORD CALLBACK uv_tty_line_read_thread(void* data) {
|
||||
NULL);
|
||||
|
||||
if (read_console_success) {
|
||||
read_bytes = bytes;
|
||||
read_bytes = bytes - 1;
|
||||
uv_utf16_to_wtf8(utf16,
|
||||
read_chars,
|
||||
&handle->tty.rd.read_line_buffer.base,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user