From 11b3663004dfebb6976b1e416b6aa70e96a743c8 Mon Sep 17 00:00:00 2001 From: Adam Morrison Date: Mon, 4 Jun 2018 13:22:49 -0700 Subject: [PATCH] Fixed a bug related to epan initialization In various places, _epan_new was called before setting the provider, so the wth field was null. This fix is necessary for the next commit, adding Secrets Description Block, as it uses this field. Change-Id: Ice8ee01c56b3e04fc71d7b2c659d9635cb366951 Reviewed-on: https://code.wireshark.org/review/28868 Petri-Dish: Anders Broman Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman --- file.c | 10 +++++----- sharkd.c | 8 ++++---- tshark.c | 8 +++----- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/file.c b/file.c index 6768395303..a61f709bce 100644 --- a/file.c +++ b/file.c @@ -267,11 +267,6 @@ cf_open(capture_file *cf, const char *fname, unsigned int type, gboolean is_temp the packets, so we know how much we'll ultimately need. */ ws_buffer_init(&cf->buf, 1500); - /* Create new epan session for dissection. - * (The old one was freed in cf_close().) - */ - cf->epan = ws_epan_new(cf); - /* We're about to start reading the file. */ cf->state = FILE_READ_IN_PROGRESS; @@ -313,6 +308,11 @@ cf_open(capture_file *cf, const char *fname, unsigned int type, gboolean is_temp cf->provider.prev_cap = NULL; cf->cum_bytes = 0; + /* Create new epan session for dissection. + * (The old one was freed in cf_close().) + */ + cf->epan = ws_epan_new(cf); + packet_list_queue_draw(); cf_callback_invoke(cf_cb_file_opened, cf); diff --git a/sharkd.c b/sharkd.c index fcc6160f1d..98ce2fc603 100644 --- a/sharkd.c +++ b/sharkd.c @@ -413,10 +413,6 @@ cf_open(capture_file *cf, const char *fname, unsigned int type, gboolean is_temp /* The open succeeded. Fill in the information for this file. */ - /* Create new epan session for dissection. */ - epan_free(cf->epan); - cf->epan = sharkd_epan_new(cf); - cf->provider.wth = wth; cf->f_datalen = 0; /* not used, but set it anyway */ @@ -442,6 +438,10 @@ cf_open(capture_file *cf, const char *fname, unsigned int type, gboolean is_temp cf->provider.prev_dis = NULL; cf->provider.prev_cap = NULL; + /* Create new epan session for dissection. */ + epan_free(cf->epan); + cf->epan = sharkd_epan_new(cf); + cf->state = FILE_READ_IN_PROGRESS; wtap_set_cb_new_ipv4(cf->provider.wth, add_ipv4_name); diff --git a/tshark.c b/tshark.c index bcbe68530d..4b5f451653 100644 --- a/tshark.c +++ b/tshark.c @@ -4064,10 +4064,6 @@ cf_open(capture_file *cf, const char *fname, unsigned int type, gboolean is_temp /* The open succeeded. Fill in the information for this file. */ - /* Create new epan session for dissection. */ - epan_free(cf->epan); - cf->epan = tshark_epan_new(cf); - cf->provider.wth = wth; cf->f_datalen = 0; /* not used, but set it anyway */ @@ -4093,7 +4089,9 @@ cf_open(capture_file *cf, const char *fname, unsigned int type, gboolean is_temp cf->provider.prev_dis = NULL; cf->provider.prev_cap = NULL; - cf->state = FILE_READ_IN_PROGRESS; + /* Create new epan session for dissection. */ + epan_free(cf->epan); + cf->epan = tshark_epan_new(cf); wtap_set_cb_new_ipv4(cf->provider.wth, add_ipv4_name); wtap_set_cb_new_ipv6(cf->provider.wth, (wtap_new_ipv6_callback_t) add_ipv6_name);