-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(host_metrics source): add defensive check to prevent panics #22604
Conversation
0820d86
to
dc0c335
Compare
eb3b531
to
325073d
Compare
325073d
to
6c84d8b
Compare
|
||
while offset < buffer.len() { | ||
let remaining_bytes = &buffer[offset..]; | ||
if remaining_bytes.len() < 4 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the fix.
let mut inet_resp_hdrs: Vec<InetResponseHeader> = Vec::new(); | ||
'outer: while let Ok(()) = socket.recv(&mut &mut receive_buffer[..]).await { | ||
let mut offset = 0; | ||
'inner: loop { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved this to a helper function
Datadog ReportBranch report: ✅ 0 Failed, 7 Passed, 0 Skipped, 25.47s Total Time |
Summary
Check the input to NativeEndian::read_u32 since the latter can panic.
Change Type
Is this a breaking change?
How did you test this PR?
On an ubuntu 24.04 instance with:
Does this PR include user facing changes?
Checklist
make check-all
is a good command to run locally. This check isdefined here. Some of these
checks might not be relevant to your PR. For Rust changes, at the very least you should run:
cargo fmt --all
cargo clippy --workspace --all-targets -- -D warnings
cargo nextest run --workspace
(alternatively, you can runcargo test --all
)Cargo.lock
), pleaserun
dd-rust-license-tool write
to regenerate the license inventory and commit the changes (if any). More details here.References
Ref #22057