[newlib-cygwin/cygwin-3_6-branch] Cygwin: pty: Fix ESC sequence parsing in pty_master_fwd_thread

Takashi Yano via Cygwin-cvs <[email protected]> Fri, 19 Dec 2025 18:28:13 +0000 (GMT)
Newsgroups gmane.os.cygwin.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=7c067a5508a2e92dcaaa52734e8c3051590ff85c

commit 7c067a5508a2e92dcaaa52734e8c3051590ff85c
Author: Takashi Yano <[email protected]>
Date:   Wed Dec 10 10:01:24 2025 +0900

    Cygwin: pty: Fix ESC sequence parsing in pty_master_fwd_thread
    
    This patch fixes the bug in ESC sequence parser for title set used
    when pseudo console is enabled in pty_master_fwd_thread(). Previously,
    if multiple ESC sequences exist in a fowarding chunk, the later one
    might not be processed appropriately.
    
    Fixes: 10d083c745dd ("Cygwin: pty: Inherit typeahead data between two input pipes.")
    Reviewed-by: Corinna Vinschen <[email protected]>, Johannes Schindelin <[email protected]>
    Signed-off-by: Takashi Yano <[email protected]>
    (cherry picked from commit 347884ef62b94295a7d7389716d2b1de115e7a28)

Diff:
---
 winsup/cygwin/fhandler/pty.cc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/winsup/cygwin/fhandler/pty.cc b/winsup/cygwin/fhandler/pty.cc
index 468bc3bc3..d2a9f3b79 100644
--- a/winsup/cygwin/fhandler/pty.cc
+++ b/winsup/cygwin/fhandler/pty.cc
@@ -2680,6 +2680,7 @@ fhandler_pty_master::pty_master_fwd_thread (const master_fwd_thread_param_t *p)
 		  {
 		    memmove (&outbuf[start_at], &outbuf[i+1], rlen-i-1);
 		    rlen = wlen = start_at + rlen - i - 1;
+		    i = start_at - 1;
 		  }
 		state = 0;
 		continue;