From 527e032b800b11fe3e816659c542e3680981b34c Mon Sep 17 00:00:00 2001 From: Gerald Combs Date: Mon, 16 Nov 2015 11:47:36 -0800 Subject: Win32: Try to fix handle leaks in capture_sync. If CreateProcess succeeds, close our child's primary thread handle. As the PROCESS_INFORMATION page at https://msdn.microsoft.com/en-us/library/windows/desktop/ms684873.aspx says, If the function succeeds, be sure to call the CloseHandle function to close the hProcess and hThread handles when you are finished with them. Otherwise, when the child process exits, the system cannot clean up the process structures for the child process because the parent process still has open handles to the child process. Closing the handle immediately doesn't seem to do any harm here, but add a note that we might want to store it and close it later. In sync_interface_stats_open, close our message and data descriptors after calling sync_pipe_wait_for_child. Ping-Bug: 11702 Change-Id: I56e0625fdceb66fba822c2dc83e07d40844329a7 Reviewed-on: https://code.wireshark.org/review/11882 Petri-Dish: Gerald Combs Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs Reviewed-by: Anders Broman --- capchild/capture_sync.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'capchild/capture_sync.c') diff --git a/capchild/capture_sync.c b/capchild/capture_sync.c index 8273ee6dac..81344be450 100644 --- a/capchild/capture_sync.c +++ b/capchild/capture_sync.c @@ -697,6 +697,8 @@ sync_pipe_start(capture_options *capture_opts, capture_session *cap_session, voi return FALSE; } cap_session->fork_child = pi.hProcess; + /* We may need to store this and close it later */ + CloseHandle(pi.hThread); g_string_free(args, TRUE); cap_session->signal_pipe_write_fd = signal_pipe_write_fd; @@ -948,6 +950,8 @@ sync_pipe_open_command(char** argv, int *data_read_fd, return -1; } *fork_child = pi.hProcess; + /* We may need to store this and close it later */ + CloseHandle(pi.hThread); g_string_free(args, TRUE); #else /* _WIN32 */ /* Create a pipe for the child process to send us messages */ @@ -1495,6 +1499,8 @@ sync_interface_stats_open(int *data_read_fd, ws_process_id *fork_child, gchar ** case, the child will get an error when writing to the broken pipe the next time, cleaning itself up then. */ ret = sync_pipe_wait_for_child(*fork_child, &wait_msg); + ws_close(message_read_fd); + ws_close(*data_read_fd); if(nread == 0) { /* We got an EOF from the sync pipe. That means that it exited before giving us any data to read. If ret is -1, we report -- cgit v1.2.1