Skip to content

Commit

Permalink
fix index out of length
Browse files Browse the repository at this point in the history
  • Loading branch information
trans-bug committed Jul 9, 2024
1 parent 673f1db commit dc9e91f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,9 @@ impl<'a, V: VectorTrait<u8>> ModbusFrame<'a, V> {
}
self.frame_start = 6;
}
if self.frame_start >= self.buf.len(){
return Err(ErrorKind::FrameBroken);
}
let unit = self.buf[self.frame_start];
let broadcast = unit == 0 || unit == 255; // some clients send broadcast to 0xff
if !broadcast && unit != self.unit_id {
Expand Down

0 comments on commit dc9e91f

Please sign in to comment.