aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2019-04-05 00:23:35 -0700
committerGuy Harris <guy@alum.mit.edu>2019-04-05 08:15:40 +0000
commit9445403f9558901dc54c88754ff21795ea1803f3 (patch)
treea5e826dcb7275201015395e84558eed0032b043c
parent053cf161734b243f836bed2870c5ea44382e2f52 (diff)
Get rid of the per-capture_file wtap_rec and Buffer.
Most code that reads from a capture_file already has its own wtap_rec and Buffer; change the remaining ones to do so as well. Change-Id: I9b7c136642bbb375848c37ebe23c9cdeffe830c3 Reviewed-on: https://code.wireshark.org/review/32732 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
-rw-r--r--cfile.h3
-rw-r--r--file.c165
-rw-r--r--file.h15
-rw-r--r--ui/proto_hier_stats.c2
-rw-r--r--ui/qt/address_editor_frame.cpp15
-rw-r--r--ui/qt/iax2_analysis_dialog.cpp19
-rw-r--r--ui/qt/models/packet_list_record.cpp2
-rw-r--r--ui/qt/packet_dialog.cpp21
-rw-r--r--ui/qt/packet_dialog.h2
-rw-r--r--ui/qt/packet_list.cpp2
-rw-r--r--ui/qt/rtp_analysis_dialog.cpp21
-rw-r--r--ui/qt/utils/frame_information.cpp2
-rw-r--r--ui/tap-rlc-graph.c19
-rw-r--r--ui/tap-tcp-stream.c18
14 files changed, 185 insertions, 121 deletions
diff --git a/cfile.h b/cfile.h
index 3c9296ba43..d6ef05b1f2 100644
--- a/cfile.h
+++ b/cfile.h
@@ -107,9 +107,6 @@ typedef struct _capture_file {
search_charset_t scs_type; /* Character set for text search */
search_direction dir; /* Direction in which to do searches */
gboolean search_in_progress; /* TRUE if user just clicked OK in the Find dialog or hit <control>N/B */
- /* packet data */
- wtap_rec rec; /* Record header */
- Buffer buf; /* Record data */
/* packet provider */
struct packet_provider_data provider;
/* frames */
diff --git a/file.c b/file.c
index 1f4b893fb0..1c4995f0cf 100644
--- a/file.c
+++ b/file.c
@@ -81,29 +81,30 @@ typedef enum {
MR_MATCHED,
MR_ERROR
} match_result;
+typedef match_result (*ws_match_function)(capture_file *, frame_data *,
+ wtap_rec *, Buffer *, void *);
static match_result match_protocol_tree(capture_file *cf, frame_data *fdata,
- void *criterion);
+ wtap_rec *, Buffer *, void *criterion);
static void match_subtree_text(proto_node *node, gpointer data);
static match_result match_summary_line(capture_file *cf, frame_data *fdata,
- void *criterion);
+ wtap_rec *, Buffer *, void *criterion);
static match_result match_narrow_and_wide(capture_file *cf, frame_data *fdata,
- void *criterion);
+ wtap_rec *, Buffer *, void *criterion);
static match_result match_narrow(capture_file *cf, frame_data *fdata,
- void *criterion);
+ wtap_rec *, Buffer *, void *criterion);
static match_result match_wide(capture_file *cf, frame_data *fdata,
- void *criterion);
+ wtap_rec *, Buffer *, void *criterion);
static match_result match_binary(capture_file *cf, frame_data *fdata,
- void *criterion);
+ wtap_rec *, Buffer *, void *criterion);
static match_result match_regex(capture_file *cf, frame_data *fdata,
- void *criterion);
+ wtap_rec *, Buffer *, void *criterion);
static match_result match_dfilter(capture_file *cf, frame_data *fdata,
- void *criterion);
+ wtap_rec *, Buffer *, void *criterion);
static match_result match_marked(capture_file *cf, frame_data *fdata,
- void *criterion);
+ wtap_rec *, Buffer *, void *criterion);
static match_result match_time_reference(capture_file *cf, frame_data *fdata,
- void *criterion);
-static gboolean find_packet(capture_file *cf,
- match_result (*match_function)(capture_file *, frame_data *, void *),
+ wtap_rec *, Buffer *, void *criterion);
+static gboolean find_packet(capture_file *cf, ws_match_function match_function,
void *criterion, search_direction dir);
static void cf_rename_failure_alert_box(const char *filename, int err);
@@ -262,13 +263,6 @@ cf_open(capture_file *cf, const char *fname, unsigned int type, gboolean is_temp
and fill in the information for this file. */
cf_close(cf);
- /* Initialize the record metadata. */
- wtap_rec_init(&cf->rec);
-
- /* XXX - we really want to initialize this after we've read all
- the packets, so we know how much we'll ultimately need. */
- ws_buffer_init(&cf->buf, 1500);
-
/* We're about to start reading the file. */
cf->state = FILE_READ_IN_PROGRESS;
@@ -385,12 +379,6 @@ cf_close(capture_file *cf)
/* no open_routine type */
cf->open_type = WTAP_TYPE_AUTO;
- /* Clean up the record metadata. */
- wtap_rec_cleanup(&cf->rec);
-
- /* Free up the packet buffer. */
- ws_buffer_free(&cf->buf);
-
dfilter_free(cf->rfcode);
cf->rfcode = NULL;
if (cf->provider.frames != NULL) {
@@ -1578,8 +1566,8 @@ cf_redissect_packets(capture_file *cf)
}
gboolean
-cf_read_record_r(capture_file *cf, const frame_data *fdata,
- wtap_rec *rec, Buffer *buf)
+cf_read_record(capture_file *cf, const frame_data *fdata,
+ wtap_rec *rec, Buffer *buf)
{
int err;
gchar *err_info;
@@ -1591,12 +1579,6 @@ cf_read_record_r(capture_file *cf, const frame_data *fdata,
return TRUE;
}
-gboolean
-cf_read_record(capture_file *cf, frame_data *fdata)
-{
- return cf_read_record_r(cf, fdata, &cf->rec, &cf->buf);
-}
-
/* Rescan the list of packets, reconstructing the CList.
"action" describes why we're doing this; it's used in the progress
@@ -1615,6 +1597,8 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item, gb
/* Rescan packets new packet list */
guint32 framenum;
frame_data *fdata;
+ wtap_rec rec;
+ Buffer buf;
progdlg_t *progbar = NULL;
GTimer *prog_timer = g_timer_new();
int count;
@@ -1639,6 +1623,9 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item, gb
g_assert(!cf->read_lock);
cf->read_lock = TRUE;
+ wtap_rec_init(&rec);
+ ws_buffer_init(&buf, 1500);
+
/* Compile the current display filter.
* We assume this will not fail since cf->dfilter is only set in
* cf_filter IFF the filter was valid.
@@ -1843,7 +1830,7 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item, gb
/* Frame dependencies from the previous dissection/filtering are no longer valid. */
fdata->dependent_of_displayed = 0;
- if (!cf_read_record(cf, fdata))
+ if (!cf_read_record(cf, fdata, &rec, &buf))
break; /* error reading the frame */
/* If the previous frame is displayed, and we haven't yet seen the
@@ -1855,7 +1842,7 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item, gb
}
add_packet_to_packet_list(fdata, cf, &edt, dfcode,
- cinfo, &cf->rec, &cf->buf,
+ cinfo, &rec, &buf,
add_to_packet_list);
/* If this frame is displayed, and this is the first frame we've
@@ -1989,6 +1976,8 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item, gb
redissect = redissect || queued_rescan_type == RESCAN_REDISSECT;
rescan_packets(cf, "Reprocessing", "all packets", redissect);
}
+ wtap_rec_cleanup(&rec);
+ ws_buffer_free(&buf);
}
@@ -2183,7 +2172,7 @@ process_specified_records(capture_file *cf, packet_range_t *range,
}
/* Get the packet */
- if (!cf_read_record_r(cf, fdata, &rec, &buf)) {
+ if (!cf_read_record(cf, fdata, &rec, &buf)) {
/* Attempt to get the packet failed. */
ret = PSP_FAILED;
break;
@@ -3064,13 +3053,14 @@ cf_find_string_protocol_tree(capture_file *cf, proto_tree *tree, match_data *md
}
static match_result
-match_protocol_tree(capture_file *cf, frame_data *fdata, void *criterion)
+match_protocol_tree(capture_file *cf, frame_data *fdata,
+ wtap_rec *rec, Buffer *buf, void *criterion)
{
match_data *mdata = (match_data *)criterion;
epan_dissect_t edt;
/* Load the frame's data. */
- if (!cf_read_record(cf, fdata)) {
+ if (!cf_read_record(cf, fdata, rec, buf)) {
/* Attempt to get the packet failed. */
return MR_ERROR;
}
@@ -3078,8 +3068,8 @@ match_protocol_tree(capture_file *cf, frame_data *fdata, void *criterion)
/* Construct the protocol tree, including the displayed text */
epan_dissect_init(&edt, cf->epan, TRUE, TRUE);
/* We don't need the column information */
- epan_dissect_run(&edt, cf->cd_t, &cf->rec,
- frame_tvbuff_new_buffer(&cf->provider, fdata, &cf->buf),
+ epan_dissect_run(&edt, cf->cd_t, rec,
+ frame_tvbuff_new_buffer(&cf->provider, fdata, buf),
fdata, NULL);
/* Iterate through all the nodes, seeing if they have text that matches. */
@@ -3169,7 +3159,8 @@ cf_find_packet_summary_line(capture_file *cf, const char *string,
}
static match_result
-match_summary_line(capture_file *cf, frame_data *fdata, void *criterion)
+match_summary_line(capture_file *cf, frame_data *fdata,
+ wtap_rec *rec, Buffer *buf, void *criterion)
{
match_data *mdata = (match_data *)criterion;
const gchar *string = mdata->string;
@@ -3184,7 +3175,7 @@ match_summary_line(capture_file *cf, frame_data *fdata, void *criterion)
size_t c_match = 0;
/* Load the frame's data. */
- if (!cf_read_record(cf, fdata)) {
+ if (!cf_read_record(cf, fdata, rec, buf)) {
/* Attempt to get the packet failed. */
return MR_ERROR;
}
@@ -3192,8 +3183,8 @@ match_summary_line(capture_file *cf, frame_data *fdata, void *criterion)
/* Don't bother constructing the protocol tree */
epan_dissect_init(&edt, cf->epan, FALSE, FALSE);
/* Get the column information */
- epan_dissect_run(&edt, cf->cd_t, &cf->rec,
- frame_tvbuff_new_buffer(&cf->provider, fdata, &cf->buf),
+ epan_dissect_run(&edt, cf->cd_t, rec,
+ frame_tvbuff_new_buffer(&cf->provider, fdata, buf),
fdata, &cf->cinfo);
/* Find the Info column */
@@ -3280,7 +3271,8 @@ cf_find_packet_data(capture_file *cf, const guint8 *string, size_t string_size,
}
static match_result
-match_narrow_and_wide(capture_file *cf, frame_data *fdata, void *criterion)
+match_narrow_and_wide(capture_file *cf, frame_data *fdata,
+ wtap_rec *rec, Buffer *buf, void *criterion)
{
cbs_t *info = (cbs_t *)criterion;
const guint8 *ascii_text = info->data;
@@ -3293,14 +3285,14 @@ match_narrow_and_wide(capture_file *cf, frame_data *fdata, void *criterion)
size_t c_match = 0;
/* Load the frame's data. */
- if (!cf_read_record(cf, fdata)) {
+ if (!cf_read_record(cf, fdata, rec, buf)) {
/* Attempt to get the packet failed. */
return MR_ERROR;
}
result = MR_NOTMATCHED;
buf_len = fdata->cap_len;
- pd = ws_buffer_start_ptr(&cf->buf);
+ pd = ws_buffer_start_ptr(buf);
i = 0;
while (i < buf_len) {
c_char = pd[i];
@@ -3329,12 +3321,13 @@ match_narrow_and_wide(capture_file *cf, frame_data *fdata, void *criterion)
}
static match_result
-match_narrow(capture_file *cf, frame_data *fdata, void *criterion)
+match_narrow(capture_file *cf, frame_data *fdata,
+ wtap_rec *rec, Buffer *buf, void *criterion)
{
- guint8 *pd;
cbs_t *info = (cbs_t *)criterion;
const guint8 *ascii_text = info->data;
size_t textlen = info->data_len;
+ guint8 *pd;
match_result result;
guint32 buf_len;
guint32 i;
@@ -3342,14 +3335,14 @@ match_narrow(capture_file *cf, frame_data *fdata, void *criterion)
size_t c_match = 0;
/* Load the frame's data. */
- if (!cf_read_record(cf, fdata)) {
+ if (!cf_read_record(cf, fdata, rec, buf)) {
/* Attempt to get the packet failed. */
return MR_ERROR;
}
result = MR_NOTMATCHED;
buf_len = fdata->cap_len;
- pd = ws_buffer_start_ptr(&cf->buf);
+ pd = ws_buffer_start_ptr(buf);
i = 0;
while (i < buf_len) {
c_char = pd[i];
@@ -3377,7 +3370,8 @@ match_narrow(capture_file *cf, frame_data *fdata, void *criterion)
}
static match_result
-match_wide(capture_file *cf, frame_data *fdata, void *criterion)
+match_wide(capture_file *cf, frame_data *fdata,
+ wtap_rec *rec, Buffer *buf, void *criterion)
{
cbs_t *info = (cbs_t *)criterion;
const guint8 *ascii_text = info->data;
@@ -3390,14 +3384,14 @@ match_wide(capture_file *cf, frame_data *fdata, void *criterion)
size_t c_match = 0;
/* Load the frame's data. */
- if (!cf_read_record(cf, fdata)) {
+ if (!cf_read_record(cf, fdata, rec, buf)) {
/* Attempt to get the packet failed. */
return MR_ERROR;
}
result = MR_NOTMATCHED;
buf_len = fdata->cap_len;
- pd = ws_buffer_start_ptr(&cf->buf);
+ pd = ws_buffer_start_ptr(buf);
i = 0;
while (i < buf_len) {
c_char = pd[i];
@@ -3425,7 +3419,8 @@ match_wide(capture_file *cf, frame_data *fdata, void *criterion)
}
static match_result
-match_binary(capture_file *cf, frame_data *fdata, void *criterion)
+match_binary(capture_file *cf, frame_data *fdata,
+ wtap_rec *rec, Buffer *buf, void *criterion)
{
cbs_t *info = (cbs_t *)criterion;
const guint8 *binary_data = info->data;
@@ -3437,14 +3432,14 @@ match_binary(capture_file *cf, frame_data *fdata, void *criterion)
size_t c_match = 0;
/* Load the frame's data. */
- if (!cf_read_record(cf, fdata)) {
+ if (!cf_read_record(cf, fdata, rec, buf)) {
/* Attempt to get the packet failed. */
return MR_ERROR;
}
result = MR_NOTMATCHED;
buf_len = fdata->cap_len;
- pd = ws_buffer_start_ptr(&cf->buf);
+ pd = ws_buffer_start_ptr(buf);
i = 0;
while (i < buf_len) {
if (pd[i] == binary_data[c_match]) {
@@ -3468,18 +3463,19 @@ match_binary(capture_file *cf, frame_data *fdata, void *criterion)
}
static match_result
-match_regex(capture_file *cf, frame_data *fdata, void *criterion _U_)
+match_regex(capture_file *cf, frame_data *fdata,
+ wtap_rec *rec, Buffer *buf, void *criterion _U_)
{
match_result result = MR_NOTMATCHED;
GMatchInfo *match_info = NULL;
/* Load the frame's data. */
- if (!cf_read_record(cf, fdata)) {
+ if (!cf_read_record(cf, fdata, rec, buf)) {
/* Attempt to get the packet failed. */
return MR_ERROR;
}
- if (g_regex_match_full(cf->regex, (const gchar *)ws_buffer_start_ptr(&cf->buf), fdata->cap_len,
+ if (g_regex_match_full(cf->regex, (const gchar *)ws_buffer_start_ptr(buf), fdata->cap_len,
0, (GRegexMatchFlags) 0, &match_info, NULL))
{
gint start_pos = 0, end_pos = 0;
@@ -3525,22 +3521,23 @@ cf_find_packet_dfilter_string(capture_file *cf, const char *filter,
}
static match_result
-match_dfilter(capture_file *cf, frame_data *fdata, void *criterion)
+match_dfilter(capture_file *cf, frame_data *fdata,
+ wtap_rec *rec, Buffer *buf, void *criterion)
{
dfilter_t *sfcode = (dfilter_t *)criterion;
epan_dissect_t edt;
match_result result;
/* Load the frame's data. */
- if (!cf_read_record(cf, fdata)) {
+ if (!cf_read_record(cf, fdata, rec, buf)) {
/* Attempt to get the packet failed. */
return MR_ERROR;
}
epan_dissect_init(&edt, cf->epan, TRUE, FALSE);
epan_dissect_prime_with_dfilter(&edt, sfcode);
- epan_dissect_run(&edt, cf->cd_t, &cf->rec,
- frame_tvbuff_new_buffer(&cf->provider, fdata, &cf->buf),
+ epan_dissect_run(&edt, cf->cd_t, rec,
+ frame_tvbuff_new_buffer(&cf->provider, fdata, buf),
fdata, NULL);
result = dfilter_apply_edt(sfcode, &edt) ? MR_MATCHED : MR_NOTMATCHED;
epan_dissect_cleanup(&edt);
@@ -3554,7 +3551,8 @@ cf_find_packet_marked(capture_file *cf, search_direction dir)
}
static match_result
-match_marked(capture_file *cf _U_, frame_data *fdata, void *criterion _U_)
+match_marked(capture_file *cf _U_, frame_data *fdata, wtap_rec *rec _U_,
+ Buffer *buf _U_, void *criterion _U_)
{
return fdata->marked ? MR_MATCHED : MR_NOTMATCHED;
}
@@ -3566,20 +3564,22 @@ cf_find_packet_time_reference(capture_file *cf, search_direction dir)
}
static match_result
-match_time_reference(capture_file *cf _U_, frame_data *fdata, void *criterion _U_)
+match_time_reference(capture_file *cf _U_, frame_data *fdata, wtap_rec *rec _U_,
+ Buffer *buf _U_, void *criterion _U_)
{
return fdata->ref_time ? MR_MATCHED : MR_NOTMATCHED;
}
static gboolean
-find_packet(capture_file *cf,
- match_result (*match_function)(capture_file *, frame_data *, void *),
+find_packet(capture_file *cf, ws_match_function match_function,
void *criterion, search_direction dir)
{
frame_data *start_fd;
guint32 framenum;
guint32 prev_framenum;
frame_data *fdata;
+ wtap_rec rec;
+ Buffer buf;
frame_data *new_fd = NULL;
progdlg_t *progbar = NULL;
GTimer *prog_timer = g_timer_new();
@@ -3591,6 +3591,9 @@ find_packet(capture_file *cf,
const char *title;
match_result result;
+ wtap_rec_init(&rec);
+ ws_buffer_init(&buf, 1500);
+
start_fd = cf->current_frame;
if (start_fd != NULL) {
prev_framenum = start_fd->num;
@@ -3691,7 +3694,7 @@ find_packet(capture_file *cf,
/* Is this packet in the display? */
if (fdata && fdata->passed_dfilter) {
/* Yes. Does it match the search criterion? */
- result = (*match_function)(cf, fdata, criterion);
+ result = (*match_function)(cf, fdata, &rec, &buf, criterion);
if (result == MR_ERROR) {
/* Error; our caller has reported the error. Go back to the frame
where we started. */
@@ -3731,11 +3734,18 @@ find_packet(capture_file *cf,
simple_message_box(ESD_TYPE_INFO, NULL,
"The capture file is probably not fully dissected.",
"End of capture exceeded.");
+ wtap_rec_cleanup(&rec);
+ ws_buffer_free(&buf);
return FALSE;
}
+ wtap_rec_cleanup(&rec);
+ ws_buffer_free(&buf);
return TRUE; /* success */
- } else
+ } else {
+ wtap_rec_cleanup(&rec);
+ ws_buffer_free(&buf);
return FALSE; /* failure */
+ }
}
gboolean
@@ -3803,6 +3813,8 @@ cf_select_packet(capture_file *cf, int row)
{
epan_dissect_t *old_edt;
frame_data *fdata;
+ wtap_rec rec;
+ Buffer buf;
/* Get the frame data struct pointer for this frame */
fdata = packet_list_get_row_data(row);
@@ -3811,8 +3823,11 @@ cf_select_packet(capture_file *cf, int row)
return;
}
+ wtap_rec_init(&rec);
+ ws_buffer_init(&buf, 1500);
+
/* Get the data in that frame. */
- if (!cf_read_record (cf, fdata)) {
+ if (!cf_read_record (cf, fdata, &rec, &buf)) {
return;
}
@@ -3826,8 +3841,8 @@ cf_select_packet(capture_file *cf, int row)
cf->edt = epan_dissect_new(cf->epan, TRUE, TRUE);
tap_build_interesting(cf->edt);
- epan_dissect_run(cf->edt, cf->cd_t, &cf->rec,
- frame_tvbuff_new_buffer(&cf->provider, cf->current_frame, &cf->buf),
+ epan_dissect_run(cf->edt, cf->cd_t, &rec,
+ frame_tvbuff_new_buffer(&cf->provider, cf->current_frame, &buf),
cf->current_frame, NULL);
dfilter_macro_build_ftv_cache(cf->edt->tree);
@@ -3835,6 +3850,8 @@ cf_select_packet(capture_file *cf, int row)
if (old_edt != NULL)
epan_dissect_free(old_edt);
+ wtap_rec_cleanup(&rec);
+ ws_buffer_free(&buf);
}
/* Unselect the selected packet, if any. */
@@ -3980,7 +3997,7 @@ cf_get_packet_comment(capture_file *cf, const frame_data *fd)
wtap_rec_init(&rec);
ws_buffer_init(&buf, 1500);
- if (!cf_read_record_r(cf, fd, &rec, &buf))
+ if (!cf_read_record(cf, fd, &rec, &buf))
{ /* XXX, what we can do here? */ }
/* rec.opt_comment is owned by the record, copy it before it is gone. */
diff --git a/file.h b/file.h
index 0d9bcb318e..18e537f151 100644
--- a/file.h
+++ b/file.h
@@ -150,19 +150,8 @@ cf_read_status_t cf_read(capture_file *cf, gboolean from_save);
* @param buf a Buffer into which to read the record's raw data
* @return TRUE if the read succeeded, FALSE if there was an error
*/
-gboolean cf_read_record_r(capture_file *cf, const frame_data *fdata,
- wtap_rec *rec, Buffer *buf);
-
-/**
- * Read the metadata and raw data for a record into a
- * capture_file structure's phdr and buf members.
- * It will pop up an alert box if there's an error.
- *
- * @param cf the capture file from which to read the record
- * @param fdata the frame_data structure for the record in question
- * @return TRUE if the read succeeded, FALSE if there was an error
- */
-gboolean cf_read_record(capture_file *cf, frame_data *fdata);
+gboolean cf_read_record(capture_file *cf, const frame_data *fdata,
+ wtap_rec *rec, Buffer *buf);
/**
* Read packets from the "end" of a capture file.
diff --git a/ui/proto_hier_stats.c b/ui/proto_hier_stats.c
index 18c559d485..67e1ff56a4 100644
--- a/ui/proto_hier_stats.c
+++ b/ui/proto_hier_stats.c
@@ -158,7 +158,7 @@ process_record(capture_file *cf, frame_data *frame, column_info *cinfo, ph_stats
/* Load the record from the capture file */
ws_buffer_init(&buf, 1500);
- if (!cf_read_record_r(cf, frame, &rec, &buf))
+ if (!cf_read_record(cf, frame, &rec, &buf))
return FALSE; /* failure */
/* Dissect the record tree not visible */
diff --git a/ui/qt/address_editor_frame.cpp b/ui/qt/address_editor_frame.cpp
index 9aa62a0ecf..2ec8dbc3ef 100644
--- a/ui/qt/address_editor_frame.cpp
+++ b/ui/qt/address_editor_frame.cpp
@@ -50,6 +50,9 @@ AddressEditorFrame::~AddressEditorFrame()
void AddressEditorFrame::editAddresses(CaptureFile &cf, int column)
{
+ wtap_rec rec;
+ Buffer buf;
+
cap_file_ = cf.capFile();
if (!cap_file_->current_frame) {
@@ -57,7 +60,11 @@ void AddressEditorFrame::editAddresses(CaptureFile &cf, int column)
return;
}
- if (!cf_read_record(cap_file_, cap_file_->current_frame)) {
+ wtap_rec_init(&rec);
+ ws_buffer_init(&buf, 1500);
+ if (!cf_read_record(cap_file_, cap_file_->current_frame, &rec, &buf)) {
+ wtap_rec_cleanup(&rec);
+ ws_buffer_free(&buf);
on_buttonBox_rejected();
return; // error reading the frame
}
@@ -70,8 +77,8 @@ void AddressEditorFrame::editAddresses(CaptureFile &cf, int column)
epan_dissect_init(&edt, cap_file_->epan, FALSE, FALSE);
col_custom_prime_edt(&edt, &cap_file_->cinfo);
- epan_dissect_run(&edt, cap_file_->cd_t, &cap_file_->rec,
- frame_tvbuff_new_buffer(&cap_file_->provider, cap_file_->current_frame, &cap_file_->buf),
+ epan_dissect_run(&edt, cap_file_->cd_t, &rec,
+ frame_tvbuff_new_buffer(&cap_file_->provider, cap_file_->current_frame, &buf),
cap_file_->current_frame, &cap_file_->cinfo);
epan_dissect_fill_in_columns(&edt, TRUE, TRUE);
@@ -88,6 +95,8 @@ void AddressEditorFrame::editAddresses(CaptureFile &cf, int column)
}
epan_dissect_cleanup(&edt);
+ wtap_rec_cleanup(&rec);
+ ws_buffer_free(&buf);
ui->addressComboBox->addItems(addresses);
ui->nameLineEdit->setFocus();
diff --git a/ui/qt/iax2_analysis_dialog.cpp b/ui/qt/iax2_analysis_dialog.cpp
index 855d318a12..a2cc543b68 100644
--- a/ui/qt/iax2_analysis_dialog.cpp
+++ b/ui/qt/iax2_analysis_dialog.cpp
@@ -311,19 +311,30 @@ Iax2AnalysisDialog::Iax2AnalysisDialog(QWidget &parent, CaptureFile &cf) :
frame_data *fdata = cap_file_.capFile()->current_frame;
- if (!cf_read_record(cap_file_.capFile(), fdata)) close();
+ wtap_rec rec;
+ Buffer buf;
+ wtap_rec_init(&rec);
+ ws_buffer_init(&buf, 1500);
+ if (!cf_read_record(cap_file_.capFile(), fdata, &rec, &buf)) {
+ wtap_rec_cleanup(&rec);
+ ws_buffer_free(&buf);
+ close();
+ return;
+ }
epan_dissect_t edt;
epan_dissect_init(&edt, cap_file_.capFile()->epan, TRUE, FALSE);
epan_dissect_prime_with_dfilter(&edt, sfcode);
- epan_dissect_run(&edt, cap_file_.capFile()->cd_t, &cap_file_.capFile()->rec,
- frame_tvbuff_new_buffer(&cap_file_.capFile()->provider, fdata, &cap_file_.capFile()->buf),
+ epan_dissect_run(&edt, cap_file_.capFile()->cd_t, &rec,
+ frame_tvbuff_new_buffer(&cap_file_.capFile()->provider, fdata, &buf),
fdata, NULL);
// This shouldn't happen (the menu item should be disabled) but check anyway
if (!dfilter_apply_edt(sfcode, &edt)) {
epan_dissect_cleanup(&edt);
+ wtap_rec_cleanup(&rec);
+ ws_buffer_free(&buf);
dfilter_free(sfcode);
err_str_ = tr("Please select an IAX2 packet.");
save_payload_error_ = TAP_IAX2_NO_PACKET_SELECTED;
@@ -340,6 +351,8 @@ Iax2AnalysisDialog::Iax2AnalysisDialog(QWidget &parent, CaptureFile &cf) :
rtpstream_id_copy_pinfo(&(edt.pi),&(rev_id_),TRUE);
epan_dissect_cleanup(&edt);
+ wtap_rec_cleanup(&rec);
+ ws_buffer_free(&buf);
#ifdef IAX2_RTP_STREAM_CHECK
rtpstream_tapinfo_t tapinfo;
diff --git a/ui/qt/models/packet_list_record.cpp b/ui/qt/models/packet_list_record.cpp
index 0d9da60b98..281e636c57 100644
--- a/ui/qt/models/packet_list_record.cpp
+++ b/ui/qt/models/packet_list_record.cpp
@@ -118,7 +118,7 @@ void PacketListRecord::dissect(capture_file *cap_file, bool dissect_color)
wtap_rec_init(&rec);
ws_buffer_init(&buf, 1500);
- if (!cf_read_record_r(cap_file, fdata_, &rec, &buf)) {
+ if (!cf_read_record(cap_file, fdata_, &rec, &buf)) {
/*
* Error reading the record.
*
diff --git a/ui/qt/packet_dialog.cpp b/ui/qt/packet_dialog.cpp
index e35ec88885..f730f32a3a 100644
--- a/ui/qt/packet_dialog.cpp
+++ b/ui/qt/packet_dialog.cpp
@@ -35,12 +35,16 @@ PacketDialog::PacketDialog(QWidget &parent, CaptureFile &cf, frame_data *fdata)
ui(new Ui::PacketDialog),
proto_tree_(NULL),
byte_view_tab_(NULL),
- rec_(wtap_rec()),
- packet_data_(NULL)
+ rec_(),
+ buf_()
{
ui->setupUi(this);
loadGeometry(parent.width() * 4 / 5, parent.height() * 4 / 5);
ui->hintLabel->setSmallText();
+
+ wtap_rec_init(&rec_);
+ ws_buffer_init(&buf_, 1500);
+
edt_.session = NULL;
edt_.tvb = NULL;
edt_.tree = NULL;
@@ -49,23 +53,17 @@ PacketDialog::PacketDialog(QWidget &parent, CaptureFile &cf, frame_data *fdata)
setWindowSubtitle(tr("Packet %1").arg(fdata->num));
- if (!cf_read_record(cap_file_.capFile(), fdata)) {
+ if (!cf_read_record(cap_file_.capFile(), fdata, &rec_, &buf_)) {
reject();
return;
}
- rec_ = cap_file_.capFile()->rec;
-
-#ifndef __clang_analyzer__
- packet_data_ = (guint8 *) g_memdup(ws_buffer_start_ptr(&(cap_file_.capFile()->buf)), fdata->cap_len);
-#endif
-
/* proto tree, visible. We need a proto tree if there's custom columns */
epan_dissect_init(&edt_, cap_file_.capFile()->epan, TRUE, TRUE);
col_custom_prime_edt(&edt_, &(cap_file_.capFile()->cinfo));
epan_dissect_run(&edt_, cap_file_.capFile()->cd_t, &rec_,
- frame_tvbuff_new(&cap_file_.capFile()->provider, fdata, packet_data_),
+ frame_tvbuff_new_buffer(&cap_file_.capFile()->provider, fdata, &buf_),
fdata, &(cap_file_.capFile()->cinfo));
epan_dissect_fill_in_columns(&edt_, TRUE, TRUE);
@@ -108,7 +106,8 @@ PacketDialog::~PacketDialog()
{
delete ui;
epan_dissect_cleanup(&edt_);
- g_free(packet_data_);
+ wtap_rec_cleanup(&rec_);
+ ws_buffer_free(&buf_);
}
void PacketDialog::captureFileClosing()
diff --git a/ui/qt/packet_dialog.h b/ui/qt/packet_dialog.h
index 7beb1ff92a..ee6af075a8 100644
--- a/ui/qt/packet_dialog.h
+++ b/ui/qt/packet_dialog.h
@@ -46,7 +46,7 @@ private:
ByteViewTab *byte_view_tab_;
epan_dissect_t edt_;
wtap_rec rec_;
- guint8 *packet_data_;
+ Buffer buf_;
};
#endif // PACKET_DIALOG_H
diff --git a/ui/qt/packet_list.cpp b/ui/qt/packet_list.cpp
index cf547eb0eb..2991a2f23b 100644
--- a/ui/qt/packet_list.cpp
+++ b/ui/qt/packet_list.cpp
@@ -1075,7 +1075,7 @@ QString PacketList::getFilterFromRowAndColumn()
wtap_rec_init(&rec);
ws_buffer_init(&buf, 1500);
- if (!cf_read_record_r(cap_file_, fdata, &rec, &buf)) {
+ if (!cf_read_record(cap_file_, fdata, &rec, &buf)) {
wtap_rec_cleanup(&rec);
ws_buffer_free(&buf);
return filter; /* error reading the record */
diff --git a/ui/qt/rtp_analysis_dialog.cpp b/ui/qt/rtp_analysis_dialog.cpp
index bc54d70820..dab1b94a5c 100644
--- a/ui/qt/rtp_analysis_dialog.cpp
+++ b/ui/qt/rtp_analysis_dialog.cpp
@@ -1558,15 +1558,24 @@ void RtpAnalysisDialog::findStreams()
frame_data *fdata = cap_file_.capFile()->current_frame;
- if (!cf_read_record(cap_file_.capFile(), fdata)) close();
+ wtap_rec rec;
+ Buffer buf;
+ wtap_rec_init(&rec);
+ ws_buffer_init(&buf, 1500);
+ if (!cf_read_record(cap_file_.capFile(), fdata, &rec, &buf)) {
+ wtap_rec_cleanup(&rec);
+ ws_buffer_free(&buf);
+ close();
+ return;
+ }
epan_dissect_t edt;
epan_dissect_init(&edt, cap_file_.capFile()->epan, TRUE, FALSE);
epan_dissect_prime_with_dfilter(&edt, sfcode);
epan_dissect_prime_with_hfid(&edt, hfid_rtp_ssrc);
- epan_dissect_run(&edt, cap_file_.capFile()->cd_t, &cap_file_.capFile()->rec,
- frame_tvbuff_new_buffer(&cap_file_.capFile()->provider, fdata, &cap_file_.capFile()->buf),
+ epan_dissect_run(&edt, cap_file_.capFile()->cd_t, &rec,
+ frame_tvbuff_new_buffer(&cap_file_.capFile()->provider, fdata, &buf),
fdata, NULL);
/*
@@ -1575,6 +1584,8 @@ void RtpAnalysisDialog::findStreams()
*/
if (!dfilter_apply_edt(sfcode, &edt)) {
epan_dissect_cleanup(&edt);
+ wtap_rec_cleanup(&rec);
+ ws_buffer_free(&buf);
dfilter_free(sfcode);
err_str_ = tr("Please select an RTPv2 packet with an SSRC value");
updateWidgets();
@@ -1594,6 +1605,8 @@ void RtpAnalysisDialog::findStreams()
if (gp == NULL || gp->len == 0) {
/* XXX - should not happen, as the filter includes rtp.ssrc */
epan_dissect_cleanup(&edt);
+ wtap_rec_cleanup(&rec);
+ ws_buffer_free(&buf);
err_str_ = tr("SSRC value not found.");
updateWidgets();
return;
@@ -1601,6 +1614,8 @@ void RtpAnalysisDialog::findStreams()
fwd_statinfo_.id.ssrc = fvalue_get_uinteger(&((field_info *)gp->pdata[0])->value);
epan_dissect_cleanup(&edt);
+ wtap_rec_cleanup(&rec);
+ ws_buffer_free(&buf);
/* Register the tap listener */
memset(&tapinfo_, 0, sizeof(rtpstream_tapinfo_t));
diff --git a/ui/qt/utils/frame_information.cpp b/ui/qt/utils/frame_information.cpp
index 6ee53d6134..9b3ea03aaa 100644
--- a/ui/qt/utils/frame_information.cpp
+++ b/ui/qt/utils/frame_information.cpp
@@ -39,7 +39,7 @@ void FrameInformation::loadFrameTree()
if ( ! fi_ || ! cap_file_ || !cap_file_->capFile())
return;
- if (!cf_read_record_r(cap_file_->capFile(), fi_, &rec_, &buf_))
+ if (!cf_read_record(cap_file_->capFile(), fi_, &rec_, &buf_))
return;
/* proto tree, visible. We need a proto tree if there's custom columns */
diff --git a/ui/tap-rlc-graph.c b/ui/tap-rlc-graph.c
index 354ee9499e..cf2f48a15b 100644
--- a/ui/tap-rlc-graph.c
+++ b/ui/tap-rlc-graph.c
@@ -96,6 +96,8 @@ rlc_lte_tap_info *select_rlc_lte_session(capture_file *cf,
gchar **err_msg)
{
frame_data *fdata;
+ wtap_rec rec;
+ Buffer buf;
epan_dissect_t edt;
dfilter_t *sfcode;
@@ -116,7 +118,11 @@ rlc_lte_tap_info *select_rlc_lte_session(capture_file *cf,
}
/* Dissect the data from the current frame. */
- if (!cf_read_record(cf, fdata)) {
+ wtap_rec_init(&rec);
+ ws_buffer_init(&buf, 1500);
+ if (!cf_read_record(cf, fdata, &rec, &buf)) {
+ wtap_rec_cleanup(&rec);
+ ws_buffer_free(&buf);
return NULL; /* error reading the record */
}
@@ -131,8 +137,8 @@ rlc_lte_tap_info *select_rlc_lte_session(capture_file *cf,
epan_dissect_init(&edt, cf->epan, TRUE, FALSE);
epan_dissect_prime_with_dfilter(&edt, sfcode);
- epan_dissect_run_with_taps(&edt, cf->cd_t, &cf->rec,
- frame_tvbuff_new_buffer(&cf->provider, fdata, &cf->buf),
+ epan_dissect_run_with_taps(&edt, cf->cd_t, &rec,
+ frame_tvbuff_new_buffer(&cf->provider, fdata, &buf),
fdata, NULL);
rel_ts = edt.pi.rel_ts;
epan_dissect_cleanup(&edt);
@@ -142,6 +148,8 @@ rlc_lte_tap_info *select_rlc_lte_session(capture_file *cf,
/* This "shouldn't happen", as the graph menu items won't
* even be enabled if the selected packet isn't an RLC PDU.
*/
+ wtap_rec_cleanup(&rec);
+ ws_buffer_free(&buf);
*err_msg = g_strdup("Selected packet doesn't have an RLC PDU");
return NULL;
}
@@ -149,6 +157,8 @@ rlc_lte_tap_info *select_rlc_lte_session(capture_file *cf,
* to select which session he wants here */
if (th.num_hdrs>1){
/* Can only handle a single RLC channel yet */
+ wtap_rec_cleanup(&rec);
+ ws_buffer_free(&buf);
*err_msg = g_strdup("The selected packet has more than one LTE RLC channel in it.");
return NULL;
}
@@ -166,6 +176,9 @@ rlc_lte_tap_info *select_rlc_lte_session(capture_file *cf,
/* Flip direction if have control PDU */
hdrs->direction = !hdrs->isControlPDU ? th.rlchdrs[0]->direction : !th.rlchdrs[0]->direction;
+ wtap_rec_cleanup(&rec);
+ ws_buffer_free(&buf);
+
return th.rlchdrs[0];
}
diff --git a/ui/tap-tcp-stream.c b/ui/tap-tcp-stream.c
index f0ce7144cd..af168941df 100644
--- a/ui/tap-tcp-stream.c
+++ b/ui/tap-tcp-stream.c
@@ -272,6 +272,8 @@ struct tcpheader *
select_tcpip_session(capture_file *cf, struct segment *hdrs)
{
frame_data *fdata;
+ wtap_rec rec;
+ Buffer buf;
epan_dissect_t edt;
dfilter_t *sfcode;
gchar *err_msg;
@@ -293,7 +295,11 @@ select_tcpip_session(capture_file *cf, struct segment *hdrs)
}
/* dissect the current record */
- if (!cf_read_record(cf, fdata)) {
+ wtap_rec_init(&rec);
+ ws_buffer_init(&buf, 1500);
+ if (!cf_read_record(cf, fdata, &rec, &buf)) {
+ wtap_rec_cleanup(&rec);
+ ws_buffer_free(&buf);
return NULL; /* error reading the record */
}
@@ -308,8 +314,8 @@ select_tcpip_session(capture_file *cf, struct segment *hdrs)
epan_dissect_init(&edt, cf->epan, TRUE, FALSE);
epan_dissect_prime_with_dfilter(&edt, sfcode);
- epan_dissect_run_with_taps(&edt, cf->cd_t, &cf->rec,
- frame_tvbuff_new_buffer(&cf->provider, fdata, &cf->buf),
+ epan_dissect_run_with_taps(&edt, cf->cd_t, &rec,
+ frame_tvbuff_new_buffer(&cf->provider, fdata, &buf),
fdata, NULL);
rel_ts = edt.pi.rel_ts;
epan_dissect_cleanup(&edt);
@@ -320,6 +326,8 @@ select_tcpip_session(capture_file *cf, struct segment *hdrs)
* even be enabled if the selected packet isn't a TCP
* segment, as tcp_graph_selected_packet_enabled() is used
* to determine whether to enable any of our menu items. */
+ wtap_rec_cleanup(&rec);
+ ws_buffer_free(&buf);
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"Selected packet isn't a TCP segment or is truncated");
return NULL;
@@ -329,6 +337,8 @@ select_tcpip_session(capture_file *cf, struct segment *hdrs)
*/
if (th.num_hdrs > 1) {
/* can only handle a single tcp layer yet */
+ wtap_rec_cleanup(&rec);
+ ws_buffer_free(&buf);
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"The selected packet has more than one TCP unique conversation "
"in it.");
@@ -352,6 +362,8 @@ select_tcpip_session(capture_file *cf, struct segment *hdrs)
hdrs->th_seglen = th.tcphdrs[0]->th_seglen;
copy_address(&hdrs->ip_src, &th.tcphdrs[0]->ip_src);
copy_address(&hdrs->ip_dst, &th.tcphdrs[0]->ip_dst);
+ wtap_rec_cleanup(&rec);
+ ws_buffer_free(&buf);
return th.tcphdrs[0];
}