Skip to content

Commit

Permalink
Reject messages with zero tags
Browse files Browse the repository at this point in the history
  • Loading branch information
int08h committed Mar 20, 2018
1 parent 1ce57a1 commit 1b21bbc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
4 changes: 4 additions & 0 deletions src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ impl RtMessage {
let mut msg = Cursor::new(bytes);

let num_tags = msg.read_u32::<LittleEndian>()?;
if num_tags == 0 {
return Err(Error::InvalidNumTags(0));
}

let mut rt_msg = RtMessage::new(num_tags);

if num_tags == 1 {
Expand Down

0 comments on commit 1b21bbc

Please sign in to comment.