aboutsummaryrefslogtreecommitdiffstats
path: root/packet-bgp.c
diff options
context:
space:
mode:
authorJun-ichiro itojun Hagino <itojun@itojun.org>1999-12-08 08:12:27 +0000
committerJun-ichiro itojun Hagino <itojun@itojun.org>1999-12-08 08:12:27 +0000
commitf877eb85c98aa335c44d1c493f7747daacf783a7 (patch)
treef0606960bf2de19d06b3ee5276fde3c1dbd2bcfe /packet-bgp.c
parent61983277828840f67fbccbe4f728b4c76929a20d (diff)
- don't print RFC1771 NLRI length if == 0
- don't do AS_PATH parsing if AS_PATH is empty, just print empty From: Greg Hankins <gregh@twoguys.org> svn path=/trunk/; revision=1241
Diffstat (limited to 'packet-bgp.c')
-rw-r--r--packet-bgp.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/packet-bgp.c b/packet-bgp.c
index 870d032580..b28a9e59af 100644
--- a/packet-bgp.c
+++ b/packet-bgp.c
@@ -390,7 +390,7 @@ dissect_bgp_update(const u_char *pd, int offset, frame_data *fd,
/* must be freed by second switch! */
/* "alen * 6" (5 digits + space) should be a good estimate
of how long the AS path string could be */
- as_path_str = malloc(alen * 6);
+ as_path_str = malloc((alen + 1) * 6);
if (as_path_str == NULL) break;
as_path_str[0] = '\0';
@@ -425,13 +425,15 @@ dissect_bgp_update(const u_char *pd, int offset, frame_data *fd,
}
}
- if (as_path_str[0] == '\0')
- goto default_attribute_top;
+ /* check for empty AS_PATH */
+ if (alen == 0)
+ strncpy(as_path_str, "empty", 6);
+
ti = proto_tree_add_text(subtree, p - pd + i, alen + aoff,
- "%s: %s (%u %s)",
- val_to_str(bgpa.bgpa_type, bgpattr_type, "Unknown"),
- as_path_str, alen + aoff, (alen + aoff == 1) ? "byte" :
- "bytes");
+ "%s: %s (%u %s)",
+ val_to_str(bgpa.bgpa_type, bgpattr_type, "Unknown"),
+ as_path_str, alen + aoff,
+ (alen + aoff == 1) ? "byte" : "bytes");
break;
case BGPTYPE_NEXT_HOP:
if (alen != 4)
@@ -598,6 +600,12 @@ dissect_bgp_update(const u_char *pd, int offset, frame_data *fd,
}
break;
case BGPTYPE_AS_PATH:
+ /* check for empty AS_PATH */
+ if (alen == 0) {
+ free(as_path_str);
+ break;
+ }
+
ti = proto_tree_add_text(subtree2, p - pd + i + aoff, alen,
"AS path: %s", as_path_str);
as_paths_tree = proto_item_add_subtree(ti, ett_bgp_as_paths);
@@ -911,12 +919,12 @@ dissect_bgp_update(const u_char *pd, int offset, frame_data *fd,
/* NLRI */
len = hlen - (p - &pd[offset]);
- ti = proto_tree_add_text(tree, p - pd, len,
- "Network layer reachability information: %u %s", len,
- (len == 1) ? "byte" : "bytes");
/* parse prefixes */
if (len > 0) {
+ ti = proto_tree_add_text(tree, p - pd, len,
+ "Network layer reachability information: %u %s", len,
+ (len == 1) ? "byte" : "bytes");
subtree = proto_item_add_subtree(ti, ett_bgp_nlri);
end = p + len;
while (p < end) {