RJ Rybarczyk
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
13 additions and
4 deletions
-
src/as_path_parser.rs
-
src/error.rs
|
|
@ -93,12 +93,16 @@ impl<'buffer> AsPathParser<'buffer> { |
|
|
|
let asn_path = self.parse_as_path(); |
|
|
|
|
|
|
|
if asn_attr_position_end != self.next { |
|
|
|
let leftover_attr_count = asn_attr_position_end - self.next; |
|
|
|
for _ in 0..leftover_attr_count { |
|
|
|
self.advance()?; |
|
|
|
let leftover_attr_count = asn_attr_position_end.checked_sub(self.next); |
|
|
|
match leftover_attr_count { |
|
|
|
Some(count) => { |
|
|
|
for _ in 0..count { |
|
|
|
self.advance()?; |
|
|
|
} |
|
|
|
} |
|
|
|
None => println!("{}", Error::AttributeOverflow), |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
asn_path |
|
|
|
} else { |
|
|
|
for _ in 0..attribute_length { |
|
|
|
|
|
@ -26,6 +26,7 @@ pub enum Error { |
|
|
|
UnexpectedEndOfBuffer, |
|
|
|
MultipleAsPaths, |
|
|
|
NoAsPathInAttributePath, |
|
|
|
AttributeOverflow, |
|
|
|
} |
|
|
|
|
|
|
|
impl Display for Error { |
|
|
@ -63,6 +64,10 @@ impl Display for Error { |
|
|
|
f, |
|
|
|
"Expected one AS_PATH attribute in BGP Attribute Path, found multiple." |
|
|
|
), |
|
|
|
AttributeOverflow => write!( |
|
|
|
f, |
|
|
|
"Overflow encountered during AS parsing. Ignoring invalid attribute." |
|
|
|
), |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|