From c6ef99f006b64ebfe182936b263900b8119b5334 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Mo=C5=84?= Date: Mon, 15 Aug 2022 10:51:20 +0200 Subject: win32-utils: Explicitly list inherited handles Windows processes inherit all inheritable handles when a new process is created using CreateProcess() with bInheritHandles set to TRUE. This can lead to undesired object lifetime extension. That is, the child process will keep ineritable handles alive even if it does not use them. Up to Windows Vista it was not possible explicitly list handles that should be inherited. Wireshark no longer works on Windows releases earlier than Vista, so use the new API without checking Windows version. Require all callers to win32_create_process() to pass in the list of handles to inherit. Set the listed handles as inheritable shortly before calling CreateProcess() and set them as not inheritable shortly after the process is created. This minimizes possibility for other callers (especially in 3rd party libraries) to inherit handles by accident. Do not terminate mmdbresolve process on exit. Instead rely on process exit when EOF is received on standard input. Previously the EOF was never received because mmdbresolve inherited both ends of standard input pipe, i.e. the fact that Wireshark closed the write end was not observed by mmdbresolve because mmdbresolve kept write handle the standard input pipe open. --- extcap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'extcap.c') diff --git a/extcap.c b/extcap.c index 9834c7dc2d..b553127c58 100644 --- a/extcap.c +++ b/extcap.c @@ -1623,7 +1623,7 @@ static gboolean extcap_create_pipe(const gchar *ifname, gchar **fifo, HANDLE *ha /* Security struct to enable Inheritable HANDLE */ memset(&security, 0, sizeof(SECURITY_ATTRIBUTES)); security.nLength = sizeof(SECURITY_ATTRIBUTES); - security.bInheritHandle = TRUE; + security.bInheritHandle = FALSE; security.lpSecurityDescriptor = NULL; /* create a namedPipe */ -- cgit v1.2.3