Skip to content

Commit e0d15dc

Browse files
committed
Check single tag message length
1 parent c5bcc50 commit e0d15dc

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/message.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ impl RtMessage {
7070

7171
/// Internal function to create a single tag message
7272
fn single_tag_message(bytes: &[u8], msg: &mut Cursor<&[u8]>) -> Result<Self, Error> {
73+
if bytes.len() < 8 {
74+
return Err(Error::MessageTooShort);
75+
}
76+
7377
let pos = msg.position() as usize;
7478
msg.set_position((pos + 4) as u64);
7579

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

83-
return Ok(rt_msg);
87+
Ok(rt_msg)
8488
}
8589

8690
/// Internal function to create a multiple tag message

0 commit comments

Comments
 (0)