extcap: fix management of multicheck and saved non boolean arguments
authorPascal Quantin <pascal.quantin@gmail.com>
Sun, 18 Sep 2016 07:31:01 +0000 (09:31 +0200)
committerRoland Knall <rknall@gmail.com>
Sun, 18 Sep 2016 09:01:08 +0000 (09:01 +0000)
Launching USBPcap without going in the interface options menu exhibits 2 bugs:
- we should restore a value only if it is not an empty string (otherwise USBPcap with an ampty --devices multicheck argument)
- when building the argument list for a non boolean argument not using the default value, do not call g_strconcat. It will
build a string concatenating the option and value (for example "--devices 1" that will be treated as a single argument).
Instead option and value must be given separately to argument list.

Bug: 12846
Change-Id: I5628cb264a7632089e6579e9ae7400e2c0e500e2
Reviewed-on: https://code.wireshark.org/review/17773
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Roland Knall <rknall@gmail.com>
extcap.c

index e8e612dac20aea33c1e4c34a4de12497aeb6695c..3672902cdd2ef7c6c8b9525690af1e2f3e33044f 100644 (file)
--- a/extcap.c
+++ b/extcap.c
@@ -618,7 +618,7 @@ static gboolean search_cb(const gchar *extcap _U_, const gchar *ifname _U_, gcha
                                 pref_title, pref_title, (const char **)arg->pref_valptr);
                     } else {
                         /* Been here before, restore stored value */
-                        if (! arg->pref_valptr && pref->varp.string)
+                        if (! arg->pref_valptr && pref->varp.string && strlen(*pref->varp.string))
                         {
                             arg->pref_valptr = pref->varp.string;
                         }
@@ -1010,9 +1010,8 @@ GPtrArray * extcap_prepare_arguments(interface_options interface_opts)
                             if ( g_strcmp0(stored, "true") == 0 )
                                 add_arg(arg_iter->call);
                         } else {
-                            gchar * call = g_strconcat(arg_iter->call, " ", stored, NULL);
-                            add_arg(call);
-                            g_free(call);
+                            add_arg(arg_iter->call);
+                            add_arg(stored);
                         }
                     } else if  (arg_iter->arg_type == EXTCAP_ARG_BOOLFLAG) {
                         if (extcap_complex_get_bool(arg_iter->default_complex))