aboutsummaryrefslogtreecommitdiffstats
path: root/extcap.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2017-03-27 12:50:26 -0700
committerGuy Harris <guy@alum.mit.edu>2017-03-27 19:51:26 +0000
commitbd3196b094ae46fa4396edbb406d68056cba6974 (patch)
treeff261deeddb8330c462969bafad6060f06df44c5 /extcap.c
parentcea97f225aa86fdc01bc47cdc095021c0ed31a1b (diff)
Don't waste time trying to run non-plain file and non-executable files.
Directories, and non-executable files, aren't going to be extcap executables. This may not make much of a difference for an installed version of Wireshark, but it makes a difference if you're running from the build directory. Change-Id: Ib9953fa04392dc7a8420ddf28bab9726e6050c12 Reviewed-on: https://code.wireshark.org/review/20752 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'extcap.c')
-rw-r--r--extcap.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/extcap.c b/extcap.c
index 3d73145123..8a07f98371 100644
--- a/extcap.c
+++ b/extcap.c
@@ -137,7 +137,8 @@ guint extcap_count(void)
/* full path to extcap binary */
g_string_printf(extcap_path, "%s" G_DIR_SEPARATOR_S "%s", dirname, file);
/* treat anything executable as an extcap binary */
- if (g_file_test(extcap_path->str, G_FILE_TEST_IS_EXECUTABLE))
+ if (g_file_test(extcap_path->str, G_FILE_TEST_IS_REGULAR) &&
+ g_file_test(extcap_path->str, G_FILE_TEST_IS_EXECUTABLE))
{
count++;
}
@@ -239,20 +240,25 @@ static gboolean extcap_foreach(gint argc, gchar **args,
/* full path to extcap binary */
g_string_printf(extcap_path, "%s" G_DIR_SEPARATOR_S "%s", dirname, file);
- if (extcap_if_exists(cb_info.ifname) && !extcap_if_exists_for_extcap(cb_info.ifname, extcap_path->str))
+ /* treat anything executable as an extcap binary */
+ if (g_file_test(extcap_path->str, G_FILE_TEST_IS_REGULAR) &&
+ g_file_test(extcap_path->str, G_FILE_TEST_IS_EXECUTABLE))
{
- continue;
- }
+ if (extcap_if_exists(cb_info.ifname) && !extcap_if_exists_for_extcap(cb_info.ifname, extcap_path->str))
+ {
+ continue;
+ }
- if (extcap_spawn_sync((gchar *) dirname, extcap_path->str, argc, args, &command_output))
- {
- cb_info.output = command_output;
- cb_info.extcap = extcap_path->str;
+ if (extcap_spawn_sync((gchar *) dirname, extcap_path->str, argc, args, &command_output))
+ {
+ cb_info.output = command_output;
+ cb_info.extcap = extcap_path->str;
- keep_going = cb(cb_info);
- }
+ keep_going = cb(cb_info);
+ }
- g_free(command_output);
+ g_free(command_output);
+ }
}
g_dir_close(dir);