Skip to content

Commit

Permalink
Check single tag message length
Browse files Browse the repository at this point in the history
  • Loading branch information
int08h committed Mar 24, 2018
1 parent c5bcc50 commit e0d15dc
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ impl RtMessage {

/// Internal function to create a single tag message
fn single_tag_message(bytes: &[u8], msg: &mut Cursor<&[u8]>) -> Result<Self, Error> {
if bytes.len() < 8 {
return Err(Error::MessageTooShort);
}

let pos = msg.position() as usize;
msg.set_position((pos + 4) as u64);

Expand All @@ -80,7 +84,7 @@ impl RtMessage {
let mut rt_msg = RtMessage::new(1);
rt_msg.add_field(tag, &value)?;

return Ok(rt_msg);
Ok(rt_msg)
}

/// Internal function to create a multiple tag message
Expand Down

0 comments on commit e0d15dc

Please sign in to comment.