4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-02-02 12:30:24 +08:00

Cygwin: pty: Fix segfault caused when tcflush() is called.

- After commit 253352e796ff9ec9a447e5375f5bc3e2b92b5293, mc (midnight
  commander) crashes with segfault if the shell is bash. This is due
  to NULL pointer access in read(). This patch fixes the issue.
  Addresses::
    https://cygwin.com/pipermail/cygwin/2021-February/247870.html
This commit is contained in:
Takashi Yano via Cygwin-patches 2021-02-21 07:45:16 +09:00 committed by Ken Brown
parent 294af062a5
commit ab8451f061

View File

@ -1474,9 +1474,12 @@ wait_retry:
out:
termios_printf ("%d = read(%p, %lu)", totalread, ptr, len);
len = (size_t) totalread;
if (ptr0)
{ /* Not tcflush() */
bool saw_eol = totalread > 0 && strchr ("\r\n", ptr0[totalread -1]);
mask_switch_to_pcon_in (false, saw_eol);
}
}
int
fhandler_pty_slave::dup (fhandler_base *child, int flags, DWORD src_pid)