Fix bug9931 'Encapsulated ethernet packets sometimes show invalid FCS'

This fixes part-1 of bug9931: the uninitialized use of a wtap_pkthdr
struct. The second part of the bug deals with dissectors calling
the Ethernet dissector for ecnapsulated Ethernet packets but using
the wrong dissector handle to do so. That's unrelated to the issue this
commit addresses, so I'm splitting them up.

Change-Id: I87be7b736f82dd74d8c261062f88143372b5344c
Reviewed-on: https://code.wireshark.org/review/848
Reviewed-by: Hadriel Kaplan <hadrielk@yahoo.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
Hadriel Kaplan 2014-03-27 17:24:20 -04:00 committed by Anders Broman
parent 9a977fc8d0
commit ca9c160933
9 changed files with 18 additions and 10 deletions

2
file.c
View File

@ -4019,7 +4019,7 @@ cf_get_comment(capture_file *cf, const frame_data *fd)
struct wtap_pkthdr phdr; /* Packet header */
Buffer buf; /* Packet data */
phdr.opt_comment = NULL;
memset(&phdr, 0, sizeof(struct wtap_pkthdr));
buffer_init(&buf, 1500);
if (!cf_read_frame_r(cf, fd, &phdr, &buf))

View File

@ -74,6 +74,8 @@ frame_cache(struct tvb_frame *frame_tvb)
{
struct wtap_pkthdr phdr; /* Packet header */
memset(&phdr, 0, sizeof(struct wtap_pkthdr));
if (frame_tvb->buf == NULL) {
frame_tvb->buf = (struct Buffer *) g_malloc(sizeof(struct Buffer));

View File

@ -143,6 +143,8 @@ process_frame(frame_data *frame, column_info *cinfo, ph_stats_t* ps)
Buffer buf;
double cur_time;
memset(&phdr, 0, sizeof(struct wtap_pkthdr));
/* Load the frame from the capture file */
buffer_init(&buf, 1500);
if (!cf_read_frame_r(&cfile, frame, &phdr, &buf))

View File

@ -96,6 +96,8 @@ frame_write(FrameRecord_t *frame, wtap *wth, wtap_dumper *pdh, Buffer *buf,
gchar *err_info;
struct wtap_pkthdr phdr;
memset(&phdr, 0, sizeof(struct wtap_pkthdr));
DEBUG_PRINT("\nDumping frame (offset=%" G_GINT64_MODIFIER "u)\n",
frame->offset);

View File

@ -3064,6 +3064,8 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
Buffer buf;
epan_dissect_t *edt = NULL;
memset(&phdr, 0, sizeof(struct wtap_pkthdr));
shb_hdr = wtap_file_get_shb_info(cf->wth);
idb_inf = wtap_file_get_idb_info(cf->wth);
#ifdef PCAP_NG_DEFAULT

View File

@ -1102,6 +1102,8 @@ packet_list_dissect_and_cache_record(PacketList *packet_list, PacketListRecord *
g_return_if_fail(packet_list);
g_return_if_fail(PACKETLIST_IS_LIST(packet_list));
memset(&phdr, 0, sizeof(struct wtap_pkthdr));
fdata = record->fdata;
if (dissect_columns) {

View File

@ -218,6 +218,8 @@ QVariant PacketListModel::data(const QModelIndex &index, int role) const
else
cinfo = NULL;
memset(&phdr, 0, sizeof(struct wtap_pkthdr));
buffer_init(&buf, 1500);
if (!cap_file_ || !cf_read_frame_r(cap_file_, fdata, &phdr, &buf)) {
/*

View File

@ -48,6 +48,7 @@ export_pdu_packet(void *tapdata, packet_info *pinfo, epan_dissect_t *edt _U_, co
int buffer_len;
guint8 *packet_buf;
memset(&pkthdr, 0, sizeof(struct wtap_pkthdr));
buffer_len = exp_pdu_data->tvb_captured_length + exp_pdu_data->tlv_buffer_len;
packet_buf = (guint8 *)g_malloc(buffer_len);
@ -64,13 +65,11 @@ export_pdu_packet(void *tapdata, packet_info *pinfo, epan_dissect_t *edt _U_, co
pkthdr.len = exp_pdu_data->tvb_reported_length + exp_pdu_data->tlv_buffer_len;
pkthdr.pkt_encap = exp_pdu_tap_data->pkt_encap;
pkthdr.interface_id = 0;
pkthdr.presence_flags = 0;
pkthdr.opt_comment = g_strdup(pinfo->pkt_comment);
pkthdr.drop_count = 0;
pkthdr.pack_flags = 0;
pkthdr.presence_flags = WTAP_HAS_CAP_LEN|WTAP_HAS_INTERFACE_ID|WTAP_HAS_TS|WTAP_HAS_PACK_FLAGS;
/* XXX: should the pkthdr.pseudo_header be set to the pinfo's pseudo-header? */
wtap_dump(exp_pdu_tap_data->wdh, &pkthdr, packet_buf, &err);
g_free(packet_buf);

View File

@ -520,16 +520,13 @@ write_current_packet (void)
struct wtap_pkthdr pkthdr;
int err;
memset(&pkthdr, 0, sizeof(struct wtap_pkthdr));
pkthdr.ts.secs = (guint32)ts_sec;
pkthdr.ts.nsecs = ts_usec * 1000;
if (ts_fmt == NULL) { ts_usec++; } /* fake packet counter */
pkthdr.caplen = pkthdr.len = prefix_length + curr_offset + eth_trailer_length;
pkthdr.pkt_encap = pcap_link_type;
pkthdr.interface_id = 0;
pkthdr.presence_flags = 0;
pkthdr.opt_comment = NULL;
pkthdr.drop_count = 0;
pkthdr.pack_flags = 0;
pkthdr.pack_flags |= direction;
pkthdr.presence_flags = WTAP_HAS_CAP_LEN|WTAP_HAS_INTERFACE_ID|WTAP_HAS_TS|WTAP_HAS_PACK_FLAGS;