Skip to content

Commit ed267f7

Browse files
committed
Fix incorrect range check in multi_tag_message()
9656fda introduced a buggy range check when ensuring that the value's end offset does not extend past the end of the payload.
1 parent 1b74b6f commit ed267f7

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/message.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ impl RtMessage {
145145
let start_idx = header_end + value_start;
146146
let end_idx = header_end + value_end;
147147

148-
if end_idx > msg_end || start_idx > end_idx {
148+
if end_idx > bytes_len || start_idx > end_idx {
149149
return Err(Error::InvalidValueLength(tag, end_idx as u32));
150150
}
151151

@@ -342,6 +342,9 @@ mod test {
342342

343343
// Entire message was read
344344
assert_eq!(encoded.position(), 72);
345+
346+
// Round-trip single-tag message
347+
RtMessage::from_bytes(&msg.encode().unwrap()).unwrap();
345348
}
346349

347350
#[test]
@@ -392,6 +395,9 @@ mod test {
392395

393396
// Everything was read
394397
assert_eq!(encoded.position() as usize, msg.encoded_size());
398+
399+
// Round-trip multi-tag message
400+
RtMessage::from_bytes(&msg.encode().unwrap()).unwrap();
395401
}
396402

397403
#[test]

0 commit comments

Comments
 (0)