diff options
author | Guy Harris <guy@alum.mit.edu> | 2015-11-16 11:49:35 -0800 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2015-11-16 21:56:12 +0000 |
commit | 90bc4af2af9c20ad956bb4debd6d949be9d69c6f (patch) | |
tree | 64d0fbc26d675a22bd8c1f0939599e0f65a47e34 | |
parent | 7a801e1c795e4d102605531638efe465755940ca (diff) | |
download | wireshark-90bc4af2af9c20ad956bb4debd6d949be9d69c6f.tar.gz |
Catch failure of _open_osfhandle().
This may at least prevent the crash in bug 11702, by not returning
"success" with bogus file handles of -1, if the opens fail due to
leaks chewing up all the available slots. More investigation needs to
be done to see why we're leaking.
Change-Id: Iaa0fdac415ea1047255d64fa8597529ad31d63d1
Reviewed-on: https://code.wireshark.org/review/11889
Reviewed-by: Guy Harris <guy@alum.mit.edu>
-rw-r--r-- | capture_sync.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/capture_sync.c b/capture_sync.c index 600266541b..70fb6fd928 100644 --- a/capture_sync.c +++ b/capture_sync.c @@ -842,7 +842,31 @@ sync_pipe_open_command(char** argv, int *data_read_fd, /* associate the operating system filehandles to C run-time file handles */ /* (good file handle infos at: http://www.flounder.com/handles.htm) */ *data_read_fd = _open_osfhandle( (long) data_pipe[PIPE_READ], _O_BINARY); + if (*data_read_fd == -1) { + *msg = g_strdup_printf("Couldn't get C file handle for data read pipe: %s", g_strerror(errno)); + CloseHandle(data_pipe[PIPE_READ]); + CloseHandle(data_pipe[PIPE_WRITE]); + CloseHandle(sync_pipe[PIPE_READ]); + CloseHandle(sync_pipe[PIPE_WRITE]); + for (i = 0; argv[i] != NULL; i++) { + g_free( (gpointer) argv[i]); + } + g_free( (gpointer) argv); + return -1; + } *message_read_fd = _open_osfhandle( (long) sync_pipe[PIPE_READ], _O_BINARY); + if (*message_read_fd == -1) { + *msg = g_strdup_printf("Couldn't get C file handle for message read pipe: %s", g_strerror(errno)); + ws_close(*data_read_fd); /* Should close data_pipe[PIPE_READ] */ + CloseHandle(data_pipe[PIPE_WRITE]); + CloseHandle(sync_pipe[PIPE_READ]); + CloseHandle(sync_pipe[PIPE_WRITE]); + for (i = 0; argv[i] != NULL; i++) { + g_free( (gpointer) argv[i]); + } + g_free( (gpointer) argv); + return -1; + } #else /* _WIN32 */ /* Create a pipe for the child process to send us messages */ if (pipe(sync_pipe) < 0) { |