summaryrefslogtreecommitdiff
path: root/src/protocol
diff options
context:
space:
mode:
Diffstat (limited to 'src/protocol')
-rw-r--r--src/protocol/gtpv1.rs5
-rw-r--r--src/protocol/l2tp.rs3
2 files changed, 8 insertions, 0 deletions
diff --git a/src/protocol/gtpv1.rs b/src/protocol/gtpv1.rs
index 3791a58..a38da21 100644
--- a/src/protocol/gtpv1.rs
+++ b/src/protocol/gtpv1.rs
@@ -74,6 +74,11 @@ fn option_decode(input: &[u8]) -> IResult<&[u8], Gtpv1Option> {
fn extension_decode(input: &[u8]) -> IResult<&[u8], Gtpv1ExtensionHeader> {
let (input, length) = number::streaming::be_u8(input)?;
+ if length * 4 < 2 {
+ return Err(nom::Err::Incomplete(nom::Needed::new(
+ (2 - length * 4).into(),
+ )));
+ }
let (input, contents) = bytes::streaming::take(length * 4 - 2)(input)?;
let (input, next_header_type) = number::streaming::be_u8(input)?;
Ok((
diff --git a/src/protocol/l2tp.rs b/src/protocol/l2tp.rs
index fdf2b69..0496f2b 100644
--- a/src/protocol/l2tp.rs
+++ b/src/protocol/l2tp.rs
@@ -303,6 +303,9 @@ fn avp_decode(input: &[u8]) -> IResult<&[u8], AvpHeader> {
* data in a single AVP. The minimum Length of an AVP is 6. If the
* length is 6, then the Attribute Value field is absent.
*/
+ if length < 6 {
+ return Err(nom::Err::Incomplete(nom::Needed::new((6 - length).into())));
+ }
let (input, attribute_value) = bytes::streaming::take(length - 6)(input)?;
Ok((