FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix based on Coverity and Sonar audits (part 8) by stelfrag · Pull Request #22336 · netdata/netdata · GitHub

Fix based on Coverity and Sonar audits (part 8) - #22336

Merged
stelfrag merged 1 commit into
netdata:masterfrom
stelfrag:cov_fix_202604_part8
May 1, 2026
Merged

Fix based on Coverity and Sonar audits (part 8)#22336
stelfrag merged 1 commit into
netdata:masterfrom
stelfrag:cov_fix_202604_part8

Conversation

Copy link
Copy Markdown
Collaborator

Sonar c:S3584 / c:S1763: spam_thread() returned directly when sendto()
failed, leaking the strdup'd per-packet strings, the packets and lengths
arrays, and the UDP socket fd. The cleanup at the end of the function
sat after an unconditional `for (;;)` loop, so it was unreachable.

Move the cleanup into the sendto() failure path (free each packets[j]
string, then free packets, free lengths, close the socket) and drop the
post-loop dead code. The function still has the same single exit path
(early return on send failure); GCC recognises the trailing infinite
loop and does not require a fall-through return.

Copy link
Copy Markdown

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

cubic-dev-ai Bot commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@stelfrag I have started the AI code review. It will take a few minutes to complete.

stelfrag marked this pull request as ready for review May 1, 2026 07:24
stelfrag requested a review from vkalintiris as a code owner May 1, 2026 07:24
Copilot AI review requested due to automatic review settings May 1, 2026 07:24
stelfrag requested a review from a team as a code owner May 1, 2026 07:24
stelfrag marked this pull request as draft May 1, 2026 07:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Pull request overview

This PR addresses an audit finding in the statsd-stress profiling test by ensuring resources are released on the sendto() failure path, removing dead/unreachable cleanup code after an infinite loop.

Changes:

  • Free per-metric packet strings when sendto() fails.
  • Free the packets/lengths arrays and close the UDP socket before returning on failure.
  • Remove unreachable post-loop cleanup code.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

stelfrag marked this pull request as ready for review May 1, 2026 08:00
stelfrag merged commit 38ca425 into netdata:master May 1, 2026
162 checks passed
stelfrag deleted the cov_fix_202604_part8 branch May 1, 2026 08:17
stelfrag mentioned this pull request Jun 22, 2026
Ferroin pushed a commit that referenced this pull request Jul 15, 2026
tests: fix statsd-stress cleanup on send-error path

Sonar c:S3584 / c:S1763: spam_thread() returned directly when sendto()
failed, leaking the strdup'd per-packet strings, the packets and lengths
arrays, and the UDP socket fd. The cleanup at the end of the function
sat after an unconditional `for (;;)` loop, so it was unreachable.

Move the cleanup into the sendto() failure path (free each packets[j]
string, then free packets, free lengths, close the socket) and drop the
post-loop dead code. The function still has the same single exit path
(early return on send failure); GCC recognises the trailing infinite
loop and does not require a fall-through return.

Co-authored-by: Costa Tsaousis <costa@netdata.cloud>
(cherry picked from commit 38ca425)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL