From Cal Turney:
Wireshark crashes when switching from a v1.11.0 profile to a v1.4.6 prof and then to a v1.5.1 profile. https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8884 #BACKPORT 1.10 svn path=/trunk/; revision=50455
This commit is contained in:
parent
6b3ac2d952
commit
bbf7636e61
229
epan/prefs.c
229
epan/prefs.c
|
@ -157,6 +157,35 @@ static const enum_val_t gui_update_channel[] = {
|
||||||
{NULL, NULL, -1}
|
{NULL, NULL, -1}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if defined(HAVE_PCAP_CREATE)
|
||||||
|
static gint num_capture_cols = 7;
|
||||||
|
static const gchar *capture_cols[7] = {
|
||||||
|
"INTERFACE",
|
||||||
|
"LINK",
|
||||||
|
"PMODE",
|
||||||
|
"SNAPLEN",
|
||||||
|
"MONITOR",
|
||||||
|
"BUFFER",
|
||||||
|
"FILTER"};
|
||||||
|
#elif defined(_WIN32) && !defined (HAVE_PCAP_CREATE)
|
||||||
|
static gint num_capture_cols = 6;
|
||||||
|
static const gchar *capture_cols[6] = {
|
||||||
|
"INTERFACE",
|
||||||
|
"LINK",
|
||||||
|
"PMODE",
|
||||||
|
"SNAPLEN",
|
||||||
|
"BUFFER",
|
||||||
|
"FILTER"};
|
||||||
|
#else
|
||||||
|
static gint num_capture_cols = 5;
|
||||||
|
static const gchar *capture_cols[5] = {
|
||||||
|
"INTERFACE",
|
||||||
|
"LINK",
|
||||||
|
"PMODE",
|
||||||
|
"SNAPLEN",
|
||||||
|
"FILTER"};
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* List of all modules with preference settings.
|
* List of all modules with preference settings.
|
||||||
*/
|
*/
|
||||||
|
@ -205,6 +234,8 @@ free_pref(gpointer data, gpointer user_data _U_)
|
||||||
pref->default_val.range = NULL;
|
pref->default_val.range = NULL;
|
||||||
break;
|
break;
|
||||||
case PREF_CUSTOM:
|
case PREF_CUSTOM:
|
||||||
|
if (strcmp(pref->name, "columns") == 0)
|
||||||
|
pref->stashed_val.boolval = TRUE;
|
||||||
pref->custom_cbs.free_cb(pref);
|
pref->custom_cbs.free_cb(pref);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1629,89 +1660,137 @@ static char * column_format_to_str_cb(pref_t* pref, gboolean default_val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/****** Capture column custom preference functions ******/
|
||||||
* Capture column custom preference functions
|
|
||||||
*/
|
|
||||||
static void capture_column_init_cb(pref_t* pref, GList** value)
|
|
||||||
{
|
|
||||||
GList *list = *value,
|
|
||||||
*list_copy = NULL;
|
|
||||||
gchar *col;
|
|
||||||
|
|
||||||
pref->varp.list = value;
|
/* This routine is only called when Wireshark is started, NOT when another profile is selected.
|
||||||
/* Copy the current list */
|
Copy the pref->capture_columns list (just loaded with the capture_cols[] struct values)
|
||||||
while (list) {
|
to prefs->default_val.list.
|
||||||
col = (gchar *)list->data;
|
*/
|
||||||
list_copy = g_list_append(list_copy, g_strdup(col));
|
static void capture_column_init_cb(pref_t* pref, GList** capture_cols_values)
|
||||||
list = list->next;
|
{
|
||||||
|
GList *ccv_list = *capture_cols_values,
|
||||||
|
*dlist = NULL;
|
||||||
|
|
||||||
|
/* */
|
||||||
|
while (ccv_list) {
|
||||||
|
dlist = g_list_append(dlist, g_strdup((gchar *)ccv_list->data));
|
||||||
|
ccv_list = ccv_list->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
pref->default_val.list = list_copy;
|
pref->default_val.list = dlist;
|
||||||
|
pref->varp.list = &prefs.capture_columns;
|
||||||
|
pref->stashed_val.boolval = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Free the prefs->capture_columns list strings and remove the list entries.
|
||||||
|
Note that since pref->varp.list points to &prefs.capture_columns, it is
|
||||||
|
also freed.
|
||||||
|
*/
|
||||||
static void capture_column_free_cb(pref_t* pref)
|
static void capture_column_free_cb(pref_t* pref)
|
||||||
{
|
{
|
||||||
GList *list = *pref->varp.list;
|
GList *clist = prefs.capture_columns;
|
||||||
gchar *col_name;
|
gchar *col_name;
|
||||||
|
|
||||||
while (list != NULL) {
|
while (clist) {
|
||||||
col_name = (gchar *)list->data;
|
col_name = (gchar *)clist->data;
|
||||||
|
|
||||||
g_free(col_name);
|
g_free(col_name);
|
||||||
list = g_list_remove_link(list, list);
|
clist = g_list_remove_link(clist, clist);
|
||||||
}
|
}
|
||||||
g_list_free(list);
|
g_list_free(clist);
|
||||||
|
prefs.capture_columns = NULL;
|
||||||
|
|
||||||
list = pref->default_val.list;
|
if (pref->stashed_val.boolval == TRUE) {
|
||||||
while (list != NULL) {
|
GList *dlist;
|
||||||
col_name = (gchar *)list->data;
|
gchar *col;
|
||||||
|
|
||||||
g_free(col_name);
|
dlist = pref->default_val.list;
|
||||||
list = g_list_remove_link(list, list);
|
while (dlist != NULL) {
|
||||||
|
col = (gchar *)dlist->data;
|
||||||
|
g_free(col);
|
||||||
|
dlist = g_list_remove_link(dlist, dlist);
|
||||||
|
}
|
||||||
|
g_list_free(dlist);
|
||||||
|
dlist = NULL;
|
||||||
}
|
}
|
||||||
g_list_free(list);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Copy pref->default_val.list to *pref->varp.list.
|
||||||
|
*/
|
||||||
static void capture_column_reset_cb(pref_t* pref)
|
static void capture_column_reset_cb(pref_t* pref)
|
||||||
{
|
{
|
||||||
GList *list_copy = *pref->varp.list,
|
GList *vlist, *dlist;
|
||||||
*list = pref->default_val.list;
|
gchar *vcol;
|
||||||
gchar *col_name;
|
|
||||||
|
/* Free the column name strings and remove the links from *pref->varp.list */
|
||||||
/* Clear the list before it's copied */
|
vlist = *pref->varp.list;
|
||||||
while (list_copy != NULL) {
|
while (vlist != NULL) {
|
||||||
col_name = (gchar *)list_copy->data;
|
vcol = (gchar *)vlist->data;
|
||||||
|
g_free(vcol);
|
||||||
g_free(col_name);
|
vlist = g_list_remove_link(vlist, vlist);
|
||||||
list_copy = g_list_remove_link(list_copy, list_copy);
|
|
||||||
}
|
}
|
||||||
|
g_list_free(vlist);
|
||||||
while (list) {
|
vlist = NULL;
|
||||||
col_name = (gchar *)list->data;
|
|
||||||
list_copy = g_list_append(list_copy, g_strdup(col_name));
|
for (dlist = pref->default_val.list; dlist != NULL; dlist = g_list_next(dlist)) {
|
||||||
list = list->next;
|
vlist = g_list_append(vlist, g_strdup((gchar *)dlist->data));
|
||||||
}
|
}
|
||||||
|
*pref->varp.list = vlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
static prefs_set_pref_e capture_column_set_cb(pref_t* pref, const gchar* value, gboolean* changed _U_)
|
static prefs_set_pref_e capture_column_set_cb(pref_t* pref, const gchar* value, gboolean* changed _U_)
|
||||||
{
|
{
|
||||||
GList *col_l, *col_l_elt;
|
GList *col_l = prefs_get_string_list(value);
|
||||||
gchar *col_name;
|
GList *col_l_elt;
|
||||||
|
gchar *col_name;
|
||||||
col_l = prefs_get_string_list(value);
|
gboolean syntax_error=FALSE;
|
||||||
|
int i;
|
||||||
|
|
||||||
if (col_l == NULL)
|
if (col_l == NULL)
|
||||||
return PREFS_SET_SYNTAX_ERR;
|
return PREFS_SET_SYNTAX_ERR;
|
||||||
|
|
||||||
g_list_free(*pref->varp.list);
|
capture_column_free_cb(pref);
|
||||||
*pref->varp.list = NULL;
|
|
||||||
|
/* If value (the list of capture.columns read from preferences) is empty, set capture.columns
|
||||||
|
to the full list of valid capture column names. */
|
||||||
|
col_l_elt = g_list_first(col_l);
|
||||||
|
if (!(*(gchar *)col_l_elt->data)) {
|
||||||
|
for (i = 0; i < num_capture_cols; i++) {
|
||||||
|
col_name = g_strdup(capture_cols[i]);
|
||||||
|
prefs.capture_columns = g_list_append(prefs.capture_columns, col_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Verify that all the column names are valid. If not, use the entire list of valid columns.
|
||||||
|
*/
|
||||||
|
while(col_l_elt) {
|
||||||
|
gboolean found_match = FALSE;
|
||||||
|
col_name = (gchar *)col_l_elt->data;
|
||||||
|
|
||||||
|
for (i = 0; i < num_capture_cols; i++) {
|
||||||
|
if (strcmp(col_name, capture_cols[i])==0) {
|
||||||
|
found_match = TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found_match) {
|
||||||
|
/* One or more cols are invalid so use the entire list of valid cols. */
|
||||||
|
for (i = 0; i < num_capture_cols; i++) {
|
||||||
|
col_name = g_strdup(capture_cols[i]);
|
||||||
|
prefs.capture_columns = g_list_append(prefs.capture_columns, col_name);
|
||||||
|
}
|
||||||
|
pref->varp.list = &prefs.capture_columns;
|
||||||
|
return PREFS_SET_SYNTAX_ERR;
|
||||||
|
}
|
||||||
|
col_l_elt = col_l_elt->next;
|
||||||
|
}
|
||||||
|
|
||||||
col_l_elt = g_list_first(col_l);
|
col_l_elt = g_list_first(col_l);
|
||||||
while(col_l_elt) {
|
while(col_l_elt) {
|
||||||
col_name = (gchar *)col_l_elt->data;
|
col_name = (gchar *)col_l_elt->data;
|
||||||
*pref->varp.list = g_list_append(*pref->varp.list, col_name);
|
prefs.capture_columns = g_list_append(prefs.capture_columns, col_name);
|
||||||
col_l_elt = col_l_elt->next;
|
col_l_elt = col_l_elt->next;
|
||||||
}
|
}
|
||||||
|
pref->varp.list = &prefs.capture_columns;
|
||||||
return PREFS_SET_OK;
|
return PREFS_SET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1723,25 +1802,20 @@ static const char * capture_column_type_name_cb(void) {
|
||||||
static char * capture_column_type_description_cb(void) {
|
static char * capture_column_type_description_cb(void) {
|
||||||
return g_strdup_printf(
|
return g_strdup_printf(
|
||||||
"List of columns to be displayed in the capture options dialog.\n"
|
"List of columns to be displayed in the capture options dialog.\n"
|
||||||
"Possible values: INTERFACE,LINK,PMODE,SNAPLEN,MONITOR,BUFFER,FILTER\n");
|
"Possible values: INTERFACE, LINK, PMODE, SNAPLEN, MONITOR, BUFFER, FILTER\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean capture_column_is_default_cb(pref_t* pref) {
|
static gboolean capture_column_is_default_cb(pref_t* pref) {
|
||||||
GList *clp = *pref->varp.list,
|
GList *pref_col = g_list_first(prefs.capture_columns),
|
||||||
*pref_col = g_list_first(clp),
|
*def_col = g_list_first(pref->default_val.list);
|
||||||
*def_col = g_list_first(pref->default_val.list);
|
|
||||||
gchar *col, *def_col_str;
|
|
||||||
gboolean is_default = TRUE;
|
gboolean is_default = TRUE;
|
||||||
|
|
||||||
/* See if the column data has changed from the default */
|
/* See if the column data has changed from the default */
|
||||||
while (pref_col && def_col) {
|
while (pref_col && def_col) {
|
||||||
col = (gchar *)pref_col->data;
|
if (strcmp((gchar *)pref_col->data, (gchar *)def_col->data) != 0) {
|
||||||
def_col_str = (gchar *) def_col->data;
|
|
||||||
if (strcmp(col, def_col_str) != 0) {
|
|
||||||
is_default = FALSE;
|
is_default = FALSE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
pref_col = pref_col->next;
|
pref_col = pref_col->next;
|
||||||
def_col = def_col->next;
|
def_col = def_col->next;
|
||||||
}
|
}
|
||||||
|
@ -1755,7 +1829,8 @@ static gboolean capture_column_is_default_cb(pref_t* pref) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static char * capture_column_to_str_cb(pref_t* pref, gboolean default_val) {
|
static char * capture_column_to_str_cb(pref_t* pref, gboolean default_val) {
|
||||||
GList *pref_l = default_val ? pref->default_val.list : *pref->varp.list;
|
|
||||||
|
GList *pref_l = default_val ? pref->default_val.list : prefs.capture_columns;
|
||||||
GList *clp = g_list_first(pref_l);
|
GList *clp = g_list_first(pref_l);
|
||||||
GList *col_l = NULL;
|
GList *col_l = NULL;
|
||||||
gchar *col, *capture_column_str;
|
gchar *col, *capture_column_str;
|
||||||
|
@ -2591,34 +2666,6 @@ pre_init_prefs(void)
|
||||||
"Source", "%s", "Destination", "%d",
|
"Source", "%s", "Destination", "%d",
|
||||||
"Protocol", "%p", "Length", "%L",
|
"Protocol", "%p", "Length", "%L",
|
||||||
"Info", "%i"};
|
"Info", "%i"};
|
||||||
#if defined(HAVE_PCAP_CREATE)
|
|
||||||
static gint num_capture_cols = 7;
|
|
||||||
static const gchar *capture_cols[7] = {
|
|
||||||
"INTERFACE",
|
|
||||||
"LINK",
|
|
||||||
"PMODE",
|
|
||||||
"SNAPLEN",
|
|
||||||
"MONITOR",
|
|
||||||
"BUFFER",
|
|
||||||
"FILTER"};
|
|
||||||
#elif defined(_WIN32) && !defined (HAVE_PCAP_CREATE)
|
|
||||||
static gint num_capture_cols = 6;
|
|
||||||
static const gchar *capture_cols[6] = {
|
|
||||||
"INTERFACE",
|
|
||||||
"LINK",
|
|
||||||
"PMODE",
|
|
||||||
"SNAPLEN",
|
|
||||||
"BUFFER",
|
|
||||||
"FILTER"};
|
|
||||||
#else
|
|
||||||
static gint num_capture_cols = 5;
|
|
||||||
static const gchar *capture_cols[5] = {
|
|
||||||
"INTERFACE",
|
|
||||||
"LINK",
|
|
||||||
"PMODE",
|
|
||||||
"SNAPLEN",
|
|
||||||
"FILTER"};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (prefs_pre_initialized)
|
if (prefs_pre_initialized)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -5575,7 +5575,7 @@ create_and_fill_model(GtkTreeView *view)
|
||||||
temp = g_strdup_printf("<b>%s</b>\n<span size='small'>%s</span>", device.display_name, device.addresses);
|
temp = g_strdup_printf("<b>%s</b>\n<span size='small'>%s</span>", device.display_name, device.addresses);
|
||||||
}
|
}
|
||||||
linkname = NULL;
|
linkname = NULL;
|
||||||
if(global_capture_session.session_started == FALSE && capture_dev_user_linktype_find(device.name) != -1) {
|
if(capture_dev_user_linktype_find(device.name) != -1) {
|
||||||
device.active_dlt = capture_dev_user_linktype_find(device.name);
|
device.active_dlt = capture_dev_user_linktype_find(device.name);
|
||||||
}
|
}
|
||||||
for (list = device.links; list != NULL; list = g_list_next(list)) {
|
for (list = device.links; list != NULL; list = g_list_next(list)) {
|
||||||
|
@ -5588,22 +5588,21 @@ create_and_fill_model(GtkTreeView *view)
|
||||||
if (!linkname)
|
if (!linkname)
|
||||||
linkname = g_strdup("unknown");
|
linkname = g_strdup("unknown");
|
||||||
pmode = capture_dev_user_pmode_find(device.name);
|
pmode = capture_dev_user_pmode_find(device.name);
|
||||||
if (global_capture_session.session_started == FALSE && pmode != -1) {
|
if (pmode != -1) {
|
||||||
device.pmode = pmode;
|
device.pmode = pmode;
|
||||||
}
|
}
|
||||||
if(global_capture_session.session_started == FALSE) {
|
hassnap = capture_dev_user_hassnap_find(device.name);
|
||||||
hassnap = capture_dev_user_hassnap_find(device.name);
|
snaplen = capture_dev_user_snaplen_find(device.name);
|
||||||
snaplen = capture_dev_user_snaplen_find(device.name);
|
if(snaplen != -1 && hassnap != -1) {
|
||||||
if(snaplen != -1 && hassnap != -1) {
|
/* Default snap lenght set in preferences */
|
||||||
/* Default snap lenght set in preferences */
|
device.snaplen = snaplen;
|
||||||
device.snaplen = snaplen;
|
device.has_snaplen = hassnap;
|
||||||
device.has_snaplen = hassnap;
|
} else {
|
||||||
} else {
|
/* No preferences set yet, use default values */
|
||||||
/* No preferences set yet, use default values */
|
device.snaplen = WTAP_MAX_PACKET_SIZE;
|
||||||
device.snaplen = WTAP_MAX_PACKET_SIZE;
|
device.has_snaplen = FALSE;
|
||||||
device.has_snaplen = FALSE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (device.has_snaplen) {
|
if (device.has_snaplen) {
|
||||||
snaplen_string = g_strdup_printf("%d", device.snaplen);
|
snaplen_string = g_strdup_printf("%d", device.snaplen);
|
||||||
} else {
|
} else {
|
||||||
|
@ -5611,10 +5610,10 @@ create_and_fill_model(GtkTreeView *view)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
|
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
|
||||||
if (global_capture_session.session_started == FALSE && capture_dev_user_buffersize_find(device.name) != -1) {
|
if (capture_dev_user_buffersize_find(device.name) != -1) {
|
||||||
buffer = capture_dev_user_buffersize_find(device.name);
|
buffer = capture_dev_user_buffersize_find(device.name);
|
||||||
device.buffer = buffer;
|
device.buffer = buffer;
|
||||||
} else if (global_capture_session.session_started == FALSE) {
|
} else {
|
||||||
device.buffer = DEFAULT_CAPTURE_BUFFER_SIZE;
|
device.buffer = DEFAULT_CAPTURE_BUFFER_SIZE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -365,7 +365,7 @@ colopts_edit_cb(GtkWidget *w, gpointer data _U_)
|
||||||
GtkWidget *colopts_edit_dlg, *main_hb, *main_grid,
|
GtkWidget *colopts_edit_dlg, *main_hb, *main_grid,
|
||||||
*ed_opts_fr, *main_vb,
|
*ed_opts_fr, *main_vb,
|
||||||
*bbox, *ok_bt, *cancel_bt, *help_bt, *column_lb,
|
*bbox, *ok_bt, *cancel_bt, *help_bt, *column_lb,
|
||||||
*col_link_lb,
|
*col_interface_lb, *col_link_lb,
|
||||||
#ifdef HAVE_PCAP_CREATE
|
#ifdef HAVE_PCAP_CREATE
|
||||||
*col_monitor_lb,
|
*col_monitor_lb,
|
||||||
#endif
|
#endif
|
||||||
|
@ -420,6 +420,21 @@ colopts_edit_cb(GtkWidget *w, gpointer data _U_)
|
||||||
gtk_widget_show(column_lb);
|
gtk_widget_show(column_lb);
|
||||||
row++;
|
row++;
|
||||||
|
|
||||||
|
/* create "Interface" label and button */
|
||||||
|
col_interface_cb = gtk_check_button_new();
|
||||||
|
ws_gtk_grid_attach_defaults(GTK_GRID(main_grid), col_interface_cb, 0, row, 1, 1);
|
||||||
|
if (!prefs.capture_columns || prefs_capture_options_dialog_column_is_visible("INTERFACE"))
|
||||||
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(col_interface_cb), TRUE);
|
||||||
|
else
|
||||||
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(col_interface_cb), FALSE);
|
||||||
|
gtk_widget_show(col_interface_cb);
|
||||||
|
|
||||||
|
col_interface_lb = gtk_label_new("Interface name");
|
||||||
|
ws_gtk_grid_attach_defaults(GTK_GRID(main_grid), col_interface_lb, 1, row, 1, 1);
|
||||||
|
gtk_misc_set_alignment(GTK_MISC(col_interface_lb), 0, 0.5f);
|
||||||
|
gtk_widget_show(col_interface_lb);
|
||||||
|
row++;
|
||||||
|
|
||||||
/* create "Link Layer" label and button */
|
/* create "Link Layer" label and button */
|
||||||
col_link_cb = gtk_check_button_new();
|
col_link_cb = gtk_check_button_new();
|
||||||
ws_gtk_grid_attach_defaults(GTK_GRID(main_grid), col_link_cb, 0, row, 1, 1);
|
ws_gtk_grid_attach_defaults(GTK_GRID(main_grid), col_link_cb, 0, row, 1, 1);
|
||||||
|
|
Loading…
Reference in New Issue