public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
From: Takashi Yano <tyan0@sourceware.org>
To: cygwin-cvs@sourceware.org
Subject: [newlib-cygwin/cygwin-3_5-branch] Cygwin: pty: Fix handle leak in master process.
Date: Tue, 13 Feb 2024 14:37:44 +0000 (GMT)	[thread overview]
Message-ID: <20240213143744.41E5C3858C52@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=a6ac7b413891b9fa4fce58bb1fb4729798b7c8a1

commit a6ac7b413891b9fa4fce58bb1fb4729798b7c8a1
Author: Takashi Yano <takashi.yano@nifty.ne.jp>
Date:   Tue Feb 13 11:17:46 2024 +0900

    Cygwin: pty: Fix handle leak in master process.
    
    If non-cygwin process is started in pty, closing from_master_nat
    pipe handle was missing in fhandler_pty_slave::input_transfer().
    This occured because the handle was duplicated but not closed.
    
    https://github.com/msys2/msys2-runtime/issues/198
    
    Fixes: 29431fcb5b14 ("Cygwin: pty: Inherit typeahead data between two input pipes.")
    Reported-by: Hakkin Lain
    Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>

Diff:
---
 winsup/cygwin/fhandler/pty.cc | 1 +
 winsup/cygwin/release/3.5.1   | 4 ++++
 2 files changed, 5 insertions(+)

diff --git a/winsup/cygwin/fhandler/pty.cc b/winsup/cygwin/fhandler/pty.cc
index 3f4bc56b5..c5c792144 100644
--- a/winsup/cygwin/fhandler/pty.cc
+++ b/winsup/cygwin/fhandler/pty.cc
@@ -3995,6 +3995,7 @@ fhandler_pty_slave::transfer_input (tty::xfer_dir dir, HANDLE from, tty *ttyp,
 	    transfered = true;;
 	}
     }
+  CloseHandle (to);
 
   /* Fix input_available_event which indicates availability in cyg pipe. */
   if (dir == tty::to_nat) /* all data is transfered to nat pipe,
diff --git a/winsup/cygwin/release/3.5.1 b/winsup/cygwin/release/3.5.1
index 81945dbda..715fcf74d 100644
--- a/winsup/cygwin/release/3.5.1
+++ b/winsup/cygwin/release/3.5.1
@@ -12,3 +12,7 @@ Fixes:
   error mode is now possible by using the new CYGWIN environment variable
   option "winjitdebug".
   Addresses: https://cygwin.com/pipermail/cygwin/2024-February/255305.html
+
+- Fix handle leak in pty master which occurs when non-cygwin process
+  is started in pty.
+  Addresses: https://github.com/msys2/msys2-runtime/issues/198

                 reply	other threads:[~2024-02-13 14:37 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240213143744.41E5C3858C52@sourceware.org \
    --to=tyan0@sourceware.org \
    --cc=cygwin-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).