summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2020-02-20 14:48:03 +0100
committerCorinna Vinschen <corinna@vinschen.de>2020-02-20 14:58:16 +0100
commitc9f153580bfb4db4f9ef023b99360d7a746bd450 (patch)
tree71d73b5331906c825f83496f248c001aa3a33efb
parent7dac41db189986bea31e07f5593c4d9b186050b1 (diff)
downloadcygnal-c9f153580bfb4db4f9ef023b99360d7a746bd450.tar.gz
cygnal-c9f153580bfb4db4f9ef023b99360d7a746bd450.tar.bz2
cygnal-c9f153580bfb4db4f9ef023b99360d7a746bd450.zip
Cygwin: console: ignore NUL byte on write in xterm emulation mode as well
A NUL byte in the output stream got accidentally not handled as IGN char in xterm console mode. The internal mbtowc conversion doesn't handle embedded NUL values gracefully, it always stops converting at NUL bytes. This broke the output of strings with embedded NUL bytes. Fix this by always skipping IGN chars in the "normal char output loop" and make sure not to move the cursor one position to the right, as in legacy console mode. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
-rw-r--r--winsup/cygwin/fhandler_console.cc4
1 files changed, 3 insertions, 1 deletions
diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc
index 66e645aa1..c062fd7f7 100644
--- a/winsup/cygwin/fhandler_console.cc
+++ b/winsup/cygwin/fhandler_console.cc
@@ -2641,6 +2641,7 @@ fhandler_console::write_normal (const unsigned char *src,
memset (&ps, 0, sizeof ps);
while (found < end
&& found - src < CONVERT_LIMIT
+ && base_chars[*found] != IGN
&& ((wincap.has_con_24bit_colors () && !con_is_legacy)
|| base_chars[*found] == NOR) )
{
@@ -2732,7 +2733,8 @@ do_print:
cursor_rel (-1, 0);
break;
case IGN:
- cursor_rel (1, 0);
+ if (!wincap.has_con_24bit_colors () || con_is_legacy)
+ cursor_rel (1, 0);
break;
case CR:
cursor_get (&x, &y);