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

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

Fix based on Coverity and Sonar audits (part 1) - #22329

Merged
stelfrag merged 3 commits into
netdata:masterfrom
stelfrag:cov_fix_202604_part1
May 6, 2026
Merged

Fix based on Coverity and Sonar audits (part 1)#22329
stelfrag merged 3 commits into
netdata:masterfrom
stelfrag:cov_fix_202604_part1

Conversation

Copy link
Copy Markdown
Collaborator

ktsaou added 3 commits April 30, 2026 09:49
Sonar c:S3519 (BLOCKER): the reverse-scan loops in
convert_cgroup_to_systemd_service() used `while (len--)` on a `size_t`,
so when the input contained no separator the loop ran to completion and
the post-decrement on len == 0 wrapped to SIZE_MAX. The subsequent
`if (len)` was true and `s[len] = '\0'` wrote far out of bounds.

The dot-search was the explicitly flagged path; the slash-search had the
same wrap pattern but was accidentally benign because `&s[SIZE_MAX + 1]`
wrapped back to `&s[0]`.

Replace both reverse scans with strrchr() and an explicit non-NULL,
non-leading check. Preserves the existing behavior for valid inputs
(separator at index > 0 truncates / repositions; separator at index 0 or
absent leaves the string unchanged) and removes the unsigned-underflow
path.
…ine_sanitized

Sonar c:S1751: comm_from_cmdline_sanitized() used `while (start)` to
process the first occurrence of `comm` in the duplicated command-line
buffer, but the body unconditionally returns and `start` is never
updated -- the loop could never iterate twice. Replace with `if (start)`
for accurate intent. No behavior change.
Sonar c:S876: ebpf_update_global_publish() computed
`zombie = exit + (-release_task)` via in-place negation of the unsigned
release_task counter. The unary minus on uint64_t is well-defined
(modular arithmetic) but is a code smell and was unnecessary -- the
intent was simple subtraction.

Replace with a direct `(long)exit - (long)release_task`, matching the
pattern used for `pvc->running` two lines above. Drop the in-place
mutation; the release_task counter is not read elsewhere after this
block. Numerical result is identical.
Copilot AI review requested due to automatic review settings April 30, 2026 13:48
stelfrag requested a review from thiagoftsm as a code owner April 30, 2026 13:48
stelfrag marked this pull request as draft April 30, 2026 13:48

Copy link
Copy Markdown

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR and write summary in the PR description

cubic-dev-ai Bot commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR and write summary in the PR description

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

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai update the PR summary

cubic-dev-ai Bot commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai update the PR summary

@stelfrag I can help — what did you want me to do?

  • Manage learnings: reply in the relevant thread and say @cubic add this to our learnings (I'll extract the learning from context). For delete/update, paste the learning link from Settings → AI review → Learnings.
  • Make a code change: @cubic fix this and push commits (or open a PR)
  • Ask a question: @cubic why is this needed?

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.


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

stelfrag marked this pull request as ready for review May 4, 2026 08:20

thiagoftsm 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

Plugins are working as expected. LGTM!

stelfrag merged commit 83179b7 into netdata:master May 6, 2026
169 of 170 checks passed
stelfrag deleted the cov_fix_202604_part1 branch May 6, 2026 19:52
stelfrag mentioned this pull request Jun 22, 2026
Ferroin pushed a commit that referenced this pull request Jul 15, 2026
* cgroups: fix unsigned underflow OOB in convert_cgroup_to_systemd_service

Sonar c:S3519 (BLOCKER): the reverse-scan loops in
convert_cgroup_to_systemd_service() used `while (len--)` on a `size_t`,
so when the input contained no separator the loop ran to completion and
the post-decrement on len == 0 wrapped to SIZE_MAX. The subsequent
`if (len)` was true and `s[len] = '\0'` wrote far out of bounds.

The dot-search was the explicitly flagged path; the slash-search had the
same wrap pattern but was accidentally benign because `&s[SIZE_MAX + 1]`
wrapped back to `&s[0]`.

Replace both reverse scans with strrchr() and an explicit non-NULL,
non-leading check. Preserves the existing behavior for valid inputs
(separator at index > 0 truncates / repositions; separator at index 0 or
absent leaves the string unchanged) and removes the unsigned-underflow
path.

* apps.plugin: replace single-iteration while with if in comm_from_cmdline_sanitized

Sonar c:S1751: comm_from_cmdline_sanitized() used `while (start)` to
process the first occurrence of `comm` in the duplicated command-line
buffer, but the body unconditionally returns and `start` is never
updated -- the loop could never iterate twice. Replace with `if (start)`
for accurate intent. No behavior change.

* ebpf.plugin: drop unsigned unary minus in zombie counter computation

Sonar c:S876: ebpf_update_global_publish() computed
`zombie = exit + (-release_task)` via in-place negation of the unsigned
release_task counter. The unary minus on uint64_t is well-defined
(modular arithmetic) but is a code smell and was unnecessary -- the
intent was simple subtraction.

Replace with a direct `(long)exit - (long)release_task`, matching the
pattern used for `pvc->running` two lines above. Drop the in-place
mutation; the release_task counter is not read elsewhere after this
block. Numerical result is identical.

---------

Co-authored-by: Costa Tsaousis <costa@netdata.cloud>
(cherry picked from commit 83179b7)
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