diff --git a/src/error.rs b/src/error.rs index 18dc057..60ba49b 100644 --- a/src/error.rs +++ b/src/error.rs @@ -34,6 +34,9 @@ pub enum Error { /// Offset within message was not 32-bit aligned InvalidOffsetAlignment(u32), + /// Invalid number of tags specified + InvalidNumTags(u32), + /// Otherwise invalid request InvalidRequest, } diff --git a/src/message.rs b/src/message.rs index 8766a8c..05c9768 100644 --- a/src/message.rs +++ b/src/message.rs @@ -47,6 +47,10 @@ impl RtMessage { let mut msg = Cursor::new(bytes); let num_tags = msg.read_u32::()?; + if num_tags == 0 { + return Err(Error::InvalidNumTags(0)); + } + let mut rt_msg = RtMessage::new(num_tags); if num_tags == 1 {