eth: fix null pointer dereference when called from Lua

At the moment, Lua dissectors always pass a NULL data parameter, so
dissectors like eth should gracefully handle that.

Bug: 14293
Change-Id: Ida4d0530a9c417db5960475274315d4acc3704a8
Fixes: v2.1.0rc0-1575-g8ec153f938 ("Have the "maybe an FCS" version of the Ethernet dissector take a data argument.")
Reviewed-on: https://code.wireshark.org/review/26431
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
Peter Wu 2018-03-11 19:49:44 +01:00 committed by Guy Harris
parent 7e842fa551
commit ba179a7ef7
1 changed files with 3 additions and 2 deletions

View File

@ -754,6 +754,7 @@ dissect_eth(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
struct eth_phdr *eth = (struct eth_phdr *)data;
proto_tree *fh_tree;
tvbuff_t *real_tvb;
guint fcs_len = eth_assume_fcs ? 4 : (eth ? eth->fcs_len : -1);
/* When capturing on a Cisco FEX, some frames (most likely all frames
captured without a vntag) have an extra destination mac prepended. */
@ -792,13 +793,13 @@ dissect_eth(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
* no FCS".
*/
add_ethernet_trailer(pinfo, tree, fh_tree, hf_eth_trailer, real_tvb, next_tvb,
eth_assume_fcs ? 4 : eth->fcs_len);
fcs_len);
} else {
/*
* XXX - this overrides Wiretap saying "this packet definitely has
* no FCS".
*/
dissect_eth_common(real_tvb, pinfo, tree, eth_assume_fcs ? 4 : eth->fcs_len);
dissect_eth_common(real_tvb, pinfo, tree, fcs_len);
}
return tvb_captured_length(tvb);
}