summaryrefslogtreecommitdiff
path: root/capchild
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2015-11-16 11:49:35 -0800
committerGuy Harris <guy@alum.mit.edu>2015-11-16 21:40:55 +0000
commit15303931f287c9a0791e9f56d31cfbb02e9ac9c6 (patch)
tree8d74312a77fcd36c28547d60389ba9e1a876f4ba /capchild
parente4da14977391dd8e24631aaadeb8e4d5d231441b (diff)
downloadwireshark-15303931f287c9a0791e9f56d31cfbb02e9ac9c6.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: I89ecff4b03bca140f05c838e1e2604a03409f803 Ping-Bug: 11702 Reviewed-on: https://code.wireshark.org/review/11881 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Guy Harris <guy@alum.mit.edu> (cherry picked from commit 9ec2cbb1c2f2917a9b9e149def8da8c072134524) Reviewed-on: https://code.wireshark.org/review/11888
Diffstat (limited to 'capchild')
-rw-r--r--capchild/capture_sync.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/capchild/capture_sync.c b/capchild/capture_sync.c
index 0b92c57028..ad84aa89e3 100644
--- a/capchild/capture_sync.c
+++ b/capchild/capture_sync.c
@@ -881,7 +881,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( (intptr_t) 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( (intptr_t) 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) {