aboutsummaryrefslogtreecommitdiffstats
path: root/extcap.c
diff options
context:
space:
mode:
authorTomasz Moń <desowin@gmail.com>2014-10-03 19:27:04 +0200
committerPascal Quantin <pascal.quantin@gmail.com>2014-10-04 11:17:01 +0000
commit20795925ffb2f9687e960de8d6798e53482cb175 (patch)
treee0b06742bd352a49fa37921cbc3e42df3c497bf1 /extcap.c
parent06926aed88eaf2d17b589beb999b079366c22380 (diff)
Update capture_opts in extcap_cleanup().
This fixes redundant extcap_pid handle close that could occur in capture_opts_del_iface() which resulted in unhandled exception on Windows. Change-Id: I06b680fcb65cd6fd854a25fb1b01248dce3251a1 Reviewed-on: https://code.wireshark.org/review/4447 Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Reviewed-by: Roland Knall <rknall@gmail.com> Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Diffstat (limited to 'extcap.c')
-rw-r--r--extcap.c32
1 files changed, 11 insertions, 21 deletions
diff --git a/extcap.c b/extcap.c
index 45801df166..1ec64fe055 100644
--- a/extcap.c
+++ b/extcap.c
@@ -434,20 +434,18 @@ void extcap_cleanup(capture_options * capture_opts) {
interface_opts.extcap_child_watch = 0;
}
-#ifdef WIN32
- if (interface_opts.extcap_pid != INVALID_HANDLE_VALUE)
+ if (interface_opts.extcap_pid != INVALID_EXTCAP_PID)
{
+#ifdef WIN32
TerminateProcess(interface_opts.extcap_pid, 0);
+#endif
g_spawn_close_pid(interface_opts.extcap_pid);
- interface_opts.extcap_pid = INVALID_HANDLE_VALUE;
- }
-#else
- if (interface_opts.extcap_pid != (GPid)-1 )
- {
- g_spawn_close_pid(interface_opts.extcap_pid);
- interface_opts.extcap_pid = (GPid)-1;
+ interface_opts.extcap_pid = INVALID_EXTCAP_PID;
}
-#endif
+
+ /* Make sure modified interface_opts is saved in capture_opts. */
+ capture_opts->ifaces = g_array_remove_index(capture_opts->ifaces, icnt);
+ g_array_insert_val(capture_opts->ifaces, icnt, interface_opts);
}
}
@@ -479,11 +477,7 @@ static void extcap_child_watch_cb(GPid pid, gint status _U_, gpointer user_data)
interface_opts = g_array_index(capture_opts->ifaces, interface_options, i);
if (interface_opts.extcap_pid == pid)
{
-#ifdef WIN32
- interface_opts.extcap_pid = INVALID_HANDLE_VALUE;
-#else
- interface_opts.extcap_pid = (GPid)-1;
-#endif
+ interface_opts.extcap_pid = INVALID_EXTCAP_PID;
interface_opts.extcap_child_watch = 0;
capture_opts->ifaces = g_array_remove_index(capture_opts->ifaces, i);
g_array_insert_val(capture_opts->ifaces, i, interface_opts);
@@ -503,11 +497,7 @@ extcaps_init_initerfaces(capture_options *capture_opts)
for (i = 0; i < capture_opts->ifaces->len; i++)
{
GPtrArray *args = NULL;
-#ifdef WIN32
- GPid pid = INVALID_HANDLE_VALUE;
-#else
- GPid pid = 0;
-#endif
+ GPid pid = INVALID_EXTCAP_PID;
gchar **tmp;
int tmp_i;
@@ -566,7 +556,7 @@ extcaps_init_initerfaces(capture_options *capture_opts)
*
* Minimum supported version of Windows: XP / Server 2003.
*/
- if (pid != INVALID_HANDLE_VALUE)
+ if (pid != INVALID_EXTCAP_PID)
{
DWORD dw;
HANDLE handles[2];