summaryrefslogtreecommitdiff
path: root/epan/dissectors/packet-sflow.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2016-06-11 18:59:25 -0700
committerGuy Harris <guy@alum.mit.edu>2016-06-12 01:59:54 +0000
commit24f02dafcd80a10558bf5afeed07a0989a6d7cc6 (patch)
treef8c040d6f41a60db18444eada5496c8461500871 /epan/dissectors/packet-sflow.c
parent4cab0516cc1108b2a9538702ea105bb6053a425f (diff)
downloadwireshark-24f02dafcd80a10558bf5afeed07a0989a6d7cc6.tar.gz
Add checks to address setting routines.
Fail if: 1) you have an AT_NONE address with data; 2) you have a non-AT_NONE address with a zero length and a non-null data pointer, or with a non-zero length and a null data pointer. When comparing addresses for equality, just make sure the types are the same, the lengths are the same and, if the lengths are non-zero, the data is the same; don't treat AT_NONE specially - the "lengths are non-zero" check will make sure we do the right thing. Make sure when we create an AT_NONE address it has a zero length and null data pointer. Change-Id: I5c452ef0d140c2d9aef3004f1cfd124a95b78fb2 Reviewed-on: https://code.wireshark.org/review/15839 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'epan/dissectors/packet-sflow.c')
-rw-r--r--epan/dissectors/packet-sflow.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/epan/dissectors/packet-sflow.c b/epan/dissectors/packet-sflow.c
index f9a0047200..991f283e8c 100644
--- a/epan/dissectors/packet-sflow.c
+++ b/epan/dissectors/packet-sflow.c
@@ -765,7 +765,7 @@ dissect_sflow_245_address_type(tvbuff_t *tvb, packet_info *pinfo,
break;
default:
/* Invalid address type, or a type we don't understand; we don't
- know the length. W e treat it as having no contents; that
+ know the length. We treat it as having no contents; that
doesn't trap us in an endless loop, as we at least include
the address type and thus at least advance the offset by 4.
Note that we have a problem, though. */
@@ -776,6 +776,9 @@ dissect_sflow_245_address_type(tvbuff_t *tvb, packet_info *pinfo,
if (addr) {
switch (len) {
+ default:
+ clear_address(addr);
+ break;
case 4:
set_address_tvb(addr, AT_IPv4, len, tvb, offset);
break;
@@ -2346,16 +2349,12 @@ dissect_sflow_245(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat
/* Unknown version; assume it's not an sFlow packet. */
return 0;
}
+
sflow_addr_type = tvb_get_ntohl(tvb, offset + 4);
switch (sflow_addr_type) {
case ADDR_TYPE_UNKNOWN:
- addr_details.type = AT_NONE;
- break;
case ADDR_TYPE_IPV4:
- addr_details.type = AT_IPv4;
- break;
case ADDR_TYPE_IPV6:
- addr_details.type = AT_IPv6;
break;
default:
@@ -2365,7 +2364,6 @@ dissect_sflow_245(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat
*/
return 0;
}
-
/* Make entries in Protocol column and Info column on summary display */
col_set_str(pinfo->cinfo, COL_PROTOCOL, "sFlow");