mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-25 01:02:24 +00:00
Fix buffer overrun on keypress in non-UTF-8 sessions.
Commit 71e42b04a's refactoring of terminal keyboard input, in the case where a Unicode string derived from a keystroke is translated into some other charset to put on the wire, had allocated the output buffer for that translation one byte too small.
This commit is contained in:
parent
e790adec4a
commit
54cd853a49
@ -2991,11 +2991,13 @@ static strbuf *term_input_data_from_unicode(
|
|||||||
* Since the terminal doesn't currently support any multibyte
|
* Since the terminal doesn't currently support any multibyte
|
||||||
* character set other than UTF-8, we can assume here that
|
* character set other than UTF-8, we can assume here that
|
||||||
* there will be at most one output byte per input wchar_t.
|
* there will be at most one output byte per input wchar_t.
|
||||||
|
* (But also we must allow space for the trailing NUL that
|
||||||
|
* wc_to_mb will write.)
|
||||||
*/
|
*/
|
||||||
char *bufptr = strbuf_append(buf, len);
|
char *bufptr = strbuf_append(buf, len + 1);
|
||||||
int rv;
|
int rv;
|
||||||
rv = wc_to_mb(term->ucsdata->line_codepage, 0, widebuf, len,
|
rv = wc_to_mb(term->ucsdata->line_codepage, 0, widebuf, len,
|
||||||
bufptr, len, NULL, term->ucsdata);
|
bufptr, len + 1, NULL, term->ucsdata);
|
||||||
buf->len = rv < 0 ? 0 : rv;
|
buf->len = rv < 0 ? 0 : rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user