Fix based on Coverity and Sonar audits (part 1)#22329
Conversation
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.
|
|
@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. |
|
@cubic-dev-ai update the PR summary |
@stelfrag I can help — what did you want me to do?
|
There was a problem hiding this comment.
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.
thiagoftsm
left a comment
There was a problem hiding this comment.
Plugins are working as expected. LGTM!



Summary