aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-bgp.c
diff options
context:
space:
mode:
authoralagoutte <alagoutte@f5534014-38df-0310-8fa8-9805f1628bb7>2011-08-24 21:37:37 +0000
committeralagoutte <alagoutte@f5534014-38df-0310-8fa8-9805f1628bb7>2011-08-24 21:37:37 +0000
commitaddd72d914cfc5f4c0203fa33a82721645659f40 (patch)
treeae30a21b4bbc4c3668c8fc69f3e92cea90a63a77 /epan/dissectors/packet-bgp.c
parentfcf52d998c1d0363c4b3c0d6edc4b11225efde84 (diff)
From astramax57 via https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6188
In some BGP captures the AS_PATH attribute was decode wrong, if the asn length determines automatically From me: Fix some whitespace... Fix error: ‘for’ loop initial declarations are only allowed in C99 mode Replace unsigned by guint git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@38723 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'epan/dissectors/packet-bgp.c')
-rw-r--r--epan/dissectors/packet-bgp.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/epan/dissectors/packet-bgp.c b/epan/dissectors/packet-bgp.c
index dcaa3ee740..96a8aecf62 100644
--- a/epan/dissectors/packet-bgp.c
+++ b/epan/dissectors/packet-bgp.c
@@ -1705,13 +1705,34 @@ dissect_bgp_update(tvbuff_t *tvb, proto_tree *tree)
asn_len = 4;
else {
if (bgp_asn_len == 0) {
+ guint unknown_segment_type = 0;
+ guint asn_is_null = 0;
+ guint d;
+ asn_len = 2;
k = q;
- while (k < end) {
- k++;
+ while (k < end)
+ {
+ type = tvb_get_guint8(tvb, k++);
+
+ /* type of segment is unknown */
+ if (type != AS_SET &&
+ type != AS_SEQUENCE &&
+ type != AS_CONFED_SEQUENCE &&
+ type != AS_CONFED_SEQUENCE)
+ unknown_segment_type = 1;
+
length = tvb_get_guint8(tvb, k++);
- k += length * 2;
- }
- asn_len = (k == end) ? 2 : 4;
+
+ /* Check for invalid ASN */
+ for (d = 0; d < length; d++)
+ {
+ if(tvb_get_ntohs(tvb, k) == 0)
+ asn_is_null = 1;
+ k += 2;
+ }
+ }
+ if(k != end || unknown_segment_type || asn_is_null)
+ asn_len = 4;
}
else {
asn_len = bgp_asn_len;