Skip to content

Fix based on Coverity and Sonar audits (part 9) - #22337

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

Fix based on Coverity and Sonar audits (part 9)#22337
stelfrag merged 1 commit into
netdata:masterfrom
stelfrag:cov_fix_202604_part9

Conversation

@stelfrag

Copy link
Copy Markdown
Collaborator

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
31.4% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@stelfrag

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

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.

Comment thread src/libnetdata/netipc/src/transport/posix/netipc_shm.c Dismissed
Comment thread src/libnetdata/netipc/src/transport/posix/netipc_uds.c Dismissed
@stelfrag
stelfrag marked this pull request as ready for review May 1, 2026 07:25
@stelfrag
stelfrag requested a review from thiagoftsm as a code owner May 1, 2026 07:25
Copilot AI review requested due to automatic review settings May 1, 2026 07:25
@stelfrag
stelfrag requested a review from vkalintiris as a code owner May 1, 2026 07:25
@stelfrag
stelfrag marked this pull request as draft May 1, 2026 07:25

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.

Pull request overview

This PR continues the audit-driven hardening of the netipc subsystem (split from #22299), focusing on overflow-safe sizing and safer stale-endpoint recovery paths across POSIX and Windows transports/services.

Changes:

  • Add overflow-checked helpers for computing header + payload message lengths and apply them in send/receive and service buffer sizing paths.
  • Harden stale socket/SHM recovery by using safer filesystem checks (lstat, O_NOFOLLOW, inode matching) before unlinking.
  • Add additional overflow guards when computing SHM region offsets/sizes (POSIX + Windows) and tighten a protocol encoder overflow check for 32-bit platforms.

Reviewed changes

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

Show a summary per file
File Description
src/libnetdata/netipc/src/transport/windows/netipc_win_shm.c Adds extra overflow guards for SHM region offset/size calculation.
src/libnetdata/netipc/src/transport/windows/netipc_named_pipe.c Introduces and uses a safe header+payload length helper in send/receive paths.
src/libnetdata/netipc/src/transport/posix/netipc_uds.c Adds safe length helper and hardens stale socket recovery to avoid unsafe unlinks.
src/libnetdata/netipc/src/transport/posix/netipc_shm.c Hardens stale SHM file recovery (no-follow, inode match) and adds region sizing overflow checks.
src/libnetdata/netipc/src/service/netipc_service_win.c Adds safe sizing helpers and applies them to buffer sizing, send, and SHM profile setup.
src/libnetdata/netipc/src/service/netipc_service.c Same as Windows service: safe sizing helpers applied to buffer sizing, send, and SHM profile setup.
src/libnetdata/netipc/src/protocol/netipc_protocol.c Limits a size_t overflow guard to 32-bit/size-constrained platforms.

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

Comment thread src/libnetdata/netipc/src/transport/windows/netipc_win_shm.c
@stelfrag
stelfrag removed the request for review from vkalintiris May 2, 2026 19:01
@stelfrag
stelfrag marked this pull request as ready for review May 2, 2026 19:01

@thiagoftsm 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.

Despiste duplicate code informed by Sonarqubecloud, the PR worked as expected on Alma 9. LGTM!

@stelfrag
stelfrag merged commit ae7cf1b into netdata:master May 3, 2026
204 of 207 checks passed
@stelfrag
stelfrag deleted the cov_fix_202604_part9 branch May 3, 2026 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants