Skip to content

Commit

Permalink
tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
pront committed Mar 6, 2025
1 parent a29b38f commit 8a8f703
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/sources/host_metrics/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,15 @@ fn parse_netlink_messages(
while offset < buffer.len() {
let remaining_bytes = &buffer[offset..];
if remaining_bytes.len() < 4 {
// Still treat this as an error since we can't even read the length
return Err(TcpError::TruncatedMessage);
}

let length = NativeEndian::read_u32(&remaining_bytes[0..4]) as usize;
if length < 4 || length > remaining_bytes.len() {
if length == 0 {
break; // Restore original behavior: treat as end of buffer
}
if length > remaining_bytes.len() {
return Err(TcpError::InvalidLength { length });
}

Expand Down

0 comments on commit 8a8f703

Please sign in to comment.