Cygwin: pty: Fix a bug in the code removing set window title sequence.

- Commit 4e08fe42c9 has a bug which
  may cause infinite loop in pty_master_fwd_thread(). This patch
  fixes the issue.
This commit is contained in:
Takashi Yano via Cygwin-patches 2020-08-31 21:02:13 +09:00 committed by Corinna Vinschen
parent 4e08fe42c9
commit 6871c8418d
1 changed files with 5 additions and 8 deletions

View File

@ -2168,15 +2168,12 @@ fhandler_pty_master::pty_master_fwd_thread ()
/* Remove Set title sequence */ /* Remove Set title sequence */
char *p0, *p1; char *p0, *p1;
p0 = outbuf; p0 = outbuf;
while ((p0 = (char *) memmem (p0, rlen, "\033]0;", 4))) while ((p0 = (char *) memmem (p0, rlen, "\033]0;", 4))
&& (p1 = (char *) memchr (p0, '\007', rlen-(p0-outbuf))))
{ {
p1 = (char *) memchr (p0, '\007', rlen - (p0 - outbuf)); memmove (p0, p1 + 1, rlen - (p1 + 1 - outbuf));
if (p1) rlen -= p1 + 1 - p0;
{ wlen = rlen;
memmove (p0, p1 + 1, rlen - (p1 + 1 - outbuf));
rlen -= p1 + 1 - p0;
wlen = rlen;
}
} }
} }
/* Remove CSI > Pm m */ /* Remove CSI > Pm m */