[PATCH] Cygwin: pty: Fix write data handling in pcon_start phase
Johannes Schindelin
Johannes.Schindelin@gmx.de
Mon Apr 6 08:14:35 GMT 2026
Hi Takashi,
On Mon, 6 Apr 2026, Takashi Yano wrote:
> If the 'for' loop in pcon_start handling in master write() does not
> break, 'ptr' and 'len' loose the chance to fixup the value. In this
> case, all data in 'ptr' are processed, so the 'len' should be 0.
> 1 byte is consistently consumed in each iteration in the 'for' loop,
> so this patch fixups 'ptr' and 'len' in every iterations instead of
> fixing-up at break.
This commit message explains the problem well, and the fix looks good to
me.
Thank you!
Johannes
>
> Fixes: 9d7440036580 ("Cygwin: pty: Fix handling of data after CSI6n response")
> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
> Reviewed-by:
> ---
> winsup/cygwin/fhandler/pty.cc | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/winsup/cygwin/fhandler/pty.cc b/winsup/cygwin/fhandler/pty.cc
> index 098c72f72..8e6fb9c23 100644
> --- a/winsup/cygwin/fhandler/pty.cc
> +++ b/winsup/cygwin/fhandler/pty.cc
> @@ -2257,6 +2257,8 @@ fhandler_pty_master::write (const void *ptr, size_t len)
> }
> else
> line_edit (p + i, 1, ti, &ret);
> + len = orig_len - i - 1;
> + ptr = p + i + 1;
> if (state == 1 && p[i] == 'R')
> state = 2;
> if (state == 2)
> @@ -2266,8 +2268,6 @@ fhandler_pty_master::write (const void *ptr, size_t len)
> the response sequence should not be written. */
> if (!get_ttyp ()->req_xfer_input)
> WriteFile (to_slave_nat, wpbuf, ixput, &n, NULL);
> - len = orig_len - i - 1;
> - ptr = p + i + 1;
> ixput = 0;
> state = 0;
> get_ttyp ()->req_xfer_input = false;
> --
> 2.51.0
>
>
>
More information about the Cygwin-patches
mailing list