Skip to content

Commit

Permalink
check overflow on reading field id
Browse files Browse the repository at this point in the history
  • Loading branch information
jp0317 authored Dec 12, 2024
1 parent 9171491 commit 67bf818
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/rs/src/protocol/compact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,16 @@ where
),
_ => {
if field_delta != 0 {
self.last_read_field_id += field_delta as i16;
self.last_read_field_id = self
.last_read_field_id
.checked_add(field_delta as i16)
.ok_or(crate::Error::Protocol(crate::ProtocolError {
kind: crate::ProtocolErrorKind::InvalidData,
message: format!(
"invalid field delta {} for last field id {}",
field_delta, self.last_read_field_id
),
}))?;
} else {
self.last_read_field_id = self.read_i16()?;
};
Expand Down

0 comments on commit 67bf818

Please sign in to comment.