Skip to content

fix(json): validate json_object before processing in json_walk function - #22309

Merged
stelfrag merged 1 commit into
netdata:masterfrom
stelfrag:fix_json_parsing
Jun 9, 2026
Merged

fix(json): validate json_object before processing in json_walk function#22309
stelfrag merged 1 commit into
netdata:masterfrom
stelfrag:fix_json_parsing

Conversation

@stelfrag

@stelfrag stelfrag commented Apr 28, 2026

Copy link
Copy Markdown
Collaborator
Summary
  • Prevent crash on an invalid health.silencers.json file eg with []

Summary by cubic

Add input validation to json_walk (JSON-C path) so it only processes JSON objects. This prevents a crash when health.silencers.json is an array (e.g., []) or otherwise invalid.

  • Bug Fixes
    • Return early if t is NULL or not json_type_object.
    • Zero-initialize JSON_ENTRY to avoid undefined reads.

Written for commit f4968f9. Summary will update on new commits. Review in cubic

@sonarqubecloud

Copy link
Copy Markdown

@stelfrag
stelfrag marked this pull request as ready for review April 28, 2026 19:42
@stelfrag
stelfrag requested a review from thiagoftsm as a code owner April 28, 2026 19:42
Copilot AI review requested due to automatic review settings April 28, 2026 19:42
@stelfrag
stelfrag requested a review from vkalintiris as a code owner April 28, 2026 19:42
@stelfrag
stelfrag marked this pull request as draft April 28, 2026 19:43

@cubic-dev-ai cubic-dev-ai Bot 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.

No issues found across 1 file

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

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

Note

Copilot was unable to run its full agentic suite in this review.

This PR prevents crashes in the JSON-C json_walk path by validating the input json_object before iterating and by avoiding undefined reads from an uninitialized JSON_ENTRY.

Changes:

  • Return early from json_walk when t is NULL or not a JSON object.
  • Zero-initialize JSON_ENTRY before use.

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

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

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


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

Comment thread src/libnetdata/json/json.c
@stelfrag
stelfrag marked this pull request as ready for review April 29, 2026 07:17
@stelfrag
stelfrag merged commit 06934c9 into netdata:master Jun 9, 2026
166 checks passed
@stelfrag
stelfrag deleted the fix_json_parsing branch June 9, 2026 10:20
@stelfrag stelfrag mentioned this pull request Jun 22, 2026
Ferroin pushed a commit that referenced this pull request Jul 15, 2026
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.

3 participants