https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=70fbf33dc9b27fcb8d90cd36a3ac591313c9a531
commit 70fbf33dc9b27fcb8d90cd36a3ac591313c9a531 Author: Takashi Yano <[email protected]> Date: Fri Dec 19 13:19:40 2025 +0900 Cygwin: pty: Make ESC sequence parser in pty_master_fwd_thread durable If the ESC comes when the state is not zero due to a broken ESC sequence, the second ESC sequence cannot be handled properly. With this patch, ESC that come in the middle of another sequence make the state machine start parsing new ESC secuence. Fixes: 10d083c745dd ("Cygwin: pty: Inherit typeahead data between two input pipes.") Suggested-by: Johannes Schindelin <[email protected]> Signed-off-by: Takashi Yano <[email protected]> (cherry picked from commit a2e8a63c90e3427a4e6f4e5a52754626fdf87599) Diff: --- winsup/cygwin/fhandler/pty.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/winsup/cygwin/fhandler/pty.cc b/winsup/cygwin/fhandler/pty.cc index a7d2bb42e..a91743875 100644 --- a/winsup/cygwin/fhandler/pty.cc +++ b/winsup/cygwin/fhandler/pty.cc @@ -2689,6 +2689,12 @@ fhandler_pty_master::pty_master_fwd_thread (const master_fwd_thread_param_t *p) } else if (state == 4) continue; + else if (outbuf[i] == '\033') + { + start_at = i; + state = 1; + continue; + } else { state = 0; @@ -2751,6 +2757,12 @@ fhandler_pty_master::pty_master_fwd_thread (const master_fwd_thread_param_t *p) i = start_at - 1; continue; } + else if (outbuf[i] == '\033') + { + start_at = i; + state = 1; + continue; + } else state = 0;
