Skip to content

Commit

Permalink
Cygwin: pipe: Give up to use query_hdl for non-cygwin apps.
Browse files Browse the repository at this point in the history
Non-cygwin app may call ReadFile() which makes NtQueryObject() for
ObjectNameInformation block in fhandler_pipe::get_query_hdl_per_process.
Therefore, stop to try to get query_hdl for non-cygwin apps.

Addresses: msys2/msys2-runtime#202

Backported-from: https://inbox.sourceware.org/cygwin-patches/20240303050915.2024-1-takashi.yano@nifty.ne.jp/
Fixes: b531d6b ("Cygwin: pipe: Introduce temporary query_hdl.")
Reported-by: Alisa Sireneva, Johannes Schindelin <Johannes.Schindelin@gmx.de>
Reviewed-by:
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  • Loading branch information
tyan0 authored and dscho committed Mar 3, 2024
1 parent bd1dc4f commit 75b5eb2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions winsup/cygwin/fhandler/pipe.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1251,6 +1251,16 @@ fhandler_pipe::get_query_hdl_per_process (WCHAR *name,

for (LONG i = (LONG) n_process - 1; i >= 0; i--)
{
/* Non-cygwin app may call ReadFile() which makes NtQueryObject()
for ObjectNameInformation block. Therefore, stop to try to get
query_hdl for non-cygwin apps. */
pid_t cygpid;
if (!(cygpid = cygwin_pid (proc_pids[i])))
continue;
pinfo p (cygpid);
if (p && ISSTATE (p, PID_NOTCYGWIN))
continue;

HANDLE proc = OpenProcess (PROCESS_DUP_HANDLE
| PROCESS_QUERY_INFORMATION,
0, proc_pids[i]);
Expand Down

0 comments on commit 75b5eb2

Please sign in to comment.