forked from osmocom/wireshark
sharkd: Fix frames request for empty "" filter
For empty filters dfilter_compile() return success but with NULL dfcode, still if used dfilter_prime_proto_tree() crashed cause of NULL df pointer. Change-Id: I0684abf8ef766a24d0c8150fef4e113813c490ea Reviewed-on: https://code.wireshark.org/review/29390 Petri-Dish: Jakub Zawadzki <darkjames-ws@darkjames.pl> Tested-by: Petri Dish Buildbot Reviewed-by: Michal Labedzki <michal.labedzki@wireshark.org> Tested-by: Michal Labedzki <michal.labedzki@wireshark.org>thomas/dect
parent
8f99b54a77
commit
3ce847e39e
6
sharkd.c
6
sharkd.c
|
@ -726,6 +726,12 @@ sharkd_filter(const char *dftext, guint8 **result)
|
|||
return -1;
|
||||
}
|
||||
|
||||
/* if dfilter_compile() success, but (dfcode == NULL) all frames are matching */
|
||||
if (dfcode == NULL) {
|
||||
*result = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
frames_count = cfile.count;
|
||||
|
||||
wtap_rec_init(&rec);
|
||||
|
|
|
@ -73,7 +73,7 @@
|
|||
|
||||
struct sharkd_filter_item
|
||||
{
|
||||
guint8 *filtered;
|
||||
guint8 *filtered; /* can be NULL if all frames are matching for given filter. */
|
||||
};
|
||||
|
||||
static GHashTable *filter_table = NULL;
|
||||
|
@ -178,7 +178,7 @@ sharkd_session_filter_free(gpointer data)
|
|||
g_free(l);
|
||||
}
|
||||
|
||||
static const guint8 *
|
||||
static const struct sharkd_filter_item *
|
||||
sharkd_session_filter_data(const char *filter)
|
||||
{
|
||||
struct sharkd_filter_item *l;
|
||||
|
@ -199,7 +199,7 @@ sharkd_session_filter_data(const char *filter)
|
|||
g_hash_table_insert(filter_table, g_strdup(filter), l);
|
||||
}
|
||||
|
||||
return l->filtered;
|
||||
return l;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -810,9 +810,12 @@ sharkd_session_process_frames(const char *buf, const jsmntok_t *tokens, int coun
|
|||
|
||||
if (tok_filter)
|
||||
{
|
||||
filter_data = sharkd_session_filter_data(tok_filter);
|
||||
if (!filter_data)
|
||||
const struct sharkd_filter_item *filter_item;
|
||||
|
||||
filter_item = sharkd_session_filter_data(tok_filter);
|
||||
if (!filter_item)
|
||||
return;
|
||||
filter_data = filter_item->filtered;
|
||||
}
|
||||
|
||||
skip = 0;
|
||||
|
@ -3160,9 +3163,12 @@ sharkd_session_process_intervals(char *buf, const jsmntok_t *tokens, int count)
|
|||
|
||||
if (tok_filter)
|
||||
{
|
||||
filter_data = sharkd_session_filter_data(tok_filter);
|
||||
if (!filter_data)
|
||||
const struct sharkd_filter_item *filter_item;
|
||||
|
||||
filter_item = sharkd_session_filter_data(tok_filter);
|
||||
if (!filter_item)
|
||||
return;
|
||||
filter_data = filter_item->filtered;
|
||||
}
|
||||
|
||||
st_total.frames = 0;
|
||||
|
|
Loading…
Reference in New Issue