summaryrefslogtreecommitdiff
path: root/epan/dissectors/packet-ip.c
diff options
context:
space:
mode:
authorJoão Valverde <joao.valverde@tecnico.ulisboa.pt>2015-09-06 22:47:05 +0100
committerAlexis La Goutte <alexis.lagoutte@gmail.com>2015-09-08 15:38:55 +0000
commitbc4bc72bd38ad9667bb27baf91eb64c654da6787 (patch)
tree3dc4de61c878eb37a1c25380fa8a9a6fb723d4c7 /epan/dissectors/packet-ip.c
parent2de799fb8d8b736d575a2a397136c46dbfb2484c (diff)
downloadwireshark-bc4bc72bd38ad9667bb27baf91eb64c654da6787.tar.gz
Detect mismatched ethertype protocol ID (IPv4) and encapsulated IP packet (IPv6)
Bug: 11458 Change-Id: I66b51654d268196da366b0e9aea6ced0076d4737 Reviewed-on: https://code.wireshark.org/review/10407 Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com> Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-ip.c')
-rw-r--r--epan/dissectors/packet-ip.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/epan/dissectors/packet-ip.c b/epan/dissectors/packet-ip.c
index 1c9cc2ac3a..b4837cf02d 100644
--- a/epan/dissectors/packet-ip.c
+++ b/epan/dissectors/packet-ip.c
@@ -2018,7 +2018,13 @@ dissect_ip_v4(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
ti = proto_tree_add_item(tree, proto_ip, tvb, offset, hlen, ENC_NA);
ip_tree = proto_item_add_subtree(ti, ett_ip);
- proto_tree_add_item(ip_tree, hf_ip_version, tvb, offset, 1, ENC_NA);
+ tf = proto_tree_add_item(ip_tree, hf_ip_version, tvb, offset, 1, ENC_NA);
+ if (hi_nibble(iph->ip_v_hl) != 4) {
+ col_add_fstr(pinfo->cinfo, COL_INFO,
+ "Bogus IPv4 version (%u, must be 4)", hi_nibble(iph->ip_v_hl));
+ expert_add_info_format(pinfo, tf, &ei_ip_bogus_ip_version, "Bogus IPv4 version");
+ return;
+ }
/* if IP is not referenced from any filters we don't need to worry about
generating any tree items. We must do this after we created the actual
@@ -3148,12 +3154,14 @@ void
proto_reg_handoff_ip(void)
{
dissector_handle_t ip_handle;
+ dissector_handle_t ipv4_handle;
ip_handle = find_dissector("ip");
ipv6_handle = find_dissector("ipv6");
data_handle = find_dissector("data");
+ ipv4_handle = create_dissector_handle(dissect_ip_v4, proto_ip);
- dissector_add_uint("ethertype", ETHERTYPE_IP, ip_handle);
+ dissector_add_uint("ethertype", ETHERTYPE_IP, ipv4_handle);
dissector_add_uint("erf.types.type", ERF_TYPE_IPV4, ip_handle);
dissector_add_uint("ppp.protocol", PPP_IP, ip_handle);
dissector_add_uint("ppp.protocol", ETHERTYPE_IP, ip_handle);