[PATCH] Cygwin: console: Ignore 0x00 on write().

Corinna Vinschen corinna-cygwin@cygwin.com
Thu Feb 20 13:45:00 GMT 2020


On Feb 20 14:35, Corinna Vinschen wrote:
> On Feb 20 20:51, Takashi Yano wrote:
> > - In xterm compatible mode, 0x00 on write() behaves incompatible
> >   with real xterm. In xterm, 0x00 completely ignored. Therefore,
> >   0x00 is ignored by console with this patch.
> > ---
> >  winsup/cygwin/fhandler_console.cc | 10 ++++++++++
> >  1 file changed, 10 insertions(+)
> > [...]
> 
> Counter-proposal:
> 
> diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc
> index 66e645aa1774..1b3aa0f34aa6 100644
> --- a/winsup/cygwin/fhandler_console.cc
> +++ b/winsup/cygwin/fhandler_console.cc
> [...]

Btw., I tested this with

  write (1, "A\0B\0C\0D", 7);

it turned out that this results in broken output even with your patch.
The reason is that a NUL byte must not (cannot) be evaluated by 
dev_console::str_to_con() -> sys_cp_mbstowcs().  The latter doesn't
handle embedded NUL bytes gracefully.


Corinna

-- 
Corinna Vinschen
Cygwin Maintainer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20200220/1b9cf50c/attachment.sig>


More information about the Cygwin-patches mailing list