diff options
author | Dario Lombardo <lomato@gmail.com> | 2018-11-01 23:55:02 +0100 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2018-11-02 14:49:14 +0000 |
commit | 779003b6a9cac281805fbcbf3ec76ec0d0d2e30b (patch) | |
tree | f8a60c8eaf26973afe9364bd1bfe7f05f678453f /extcap.c | |
parent | 8e4552ad23248710d1a1421b39734fb3172ab097 (diff) |
extcap: add check before using pipedata.
In line 1131 the check assumes that pipedata can be NULL. All subsequent
uses require it is not NULL, otherwise it may result in a NULL
dereference.
Found by Clang.
Change-Id: I9bd35b6213adfb41de2e96d5cc6da2b3bac4dd95
Reviewed-on: https://code.wireshark.org/review/30478
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Reviewed-by: Roland Knall <rknall@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'extcap.c')
-rw-r--r-- | extcap.c | 30 |
1 files changed, 16 insertions, 14 deletions
@@ -1187,23 +1187,25 @@ void extcap_if_cleanup(capture_options *capture_opts, gchar **errormsg) interface_opts->extcap_child_watch = 0; } - if (pipedata->stdout_fd > 0) - { - ws_close(pipedata->stdout_fd); - } + if (pipedata) { + if (pipedata->stdout_fd > 0) + { + ws_close(pipedata->stdout_fd); + } - if (pipedata->stderr_fd > 0) - { - ws_close(pipedata->stderr_fd); - } + if (pipedata->stderr_fd > 0) + { + ws_close(pipedata->stderr_fd); + } - if (interface_opts->extcap_pid != WS_INVALID_PID) - { - ws_pipe_close((ws_pipe_t *) interface_opts->extcap_pipedata); - interface_opts->extcap_pid = WS_INVALID_PID; + if (interface_opts->extcap_pid != WS_INVALID_PID) + { + ws_pipe_close(pipedata); + interface_opts->extcap_pid = WS_INVALID_PID; - g_free(interface_opts->extcap_pipedata); - interface_opts->extcap_pipedata = NULL; + g_free(pipedata); + interface_opts->extcap_pipedata = NULL; + } } } } |