[newlib-cygwin/cygwin-3_6-branch] Cygwin: pty: Fix write data handling in pcon_start phase
Takashi Yano via Cygwin-cvs <[email protected]> Mon, 6 Apr 2026 12:18:36 +0000 (GMT)
| Newsgroups | gmane.os.cygwin.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D25a9e4de1df= 282cc32534b13cdf267a410a7de86 commit 25a9e4de1df282cc32534b13cdf267a410a7de86 Author: Takashi Yano <[email protected]> Date: Wed Mar 25 19:32:16 2026 +0900 Cygwin: pty: Fix write data handling in pcon_start phase =20 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. =20 Fixes: 9d7440036580 ("Cygwin: pty: Fix handling of data after CSI6n res= ponse") Signed-off-by: Takashi Yano <[email protected]> Reviewed-by: Johannes Schindelin <[email protected]> (cherry picked from commit c8bbec4c551f9b606305d87a165909facf442e0b) Diff: --- 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 aa48fd017..29f780a39 100644 --- a/winsup/cygwin/fhandler/pty.cc +++ b/winsup/cygwin/fhandler/pty.cc @@ -2218,6 +2218,8 @@ fhandler_pty_master::write (const void *ptr, size_t l= en) } else line_edit (p + i, 1, ti, &ret); + len =3D orig_len - i - 1; + ptr =3D p + i + 1; if (state =3D=3D 1 && p[i] =3D=3D 'R') state =3D 2; if (state =3D=3D 2) @@ -2227,8 +2229,6 @@ fhandler_pty_master::write (const void *ptr, size_t l= en) the response sequence should not be written. */ if (!get_ttyp ()->req_xfer_input) WriteFile (to_slave_nat, wpbuf, ixput, &n, NULL); - len =3D orig_len - i - 1; - ptr =3D p + i + 1; ixput =3D 0; state =3D 0; get_ttyp ()->req_xfer_input =3D false;