Skip to content

tokener: validate depth and printbuf, guard key strdup - #182

Open
prownd wants to merge 1 commit into
rsyslog:mainfrom
prownd:tokener-validate-depth-and-printbuf-guard-key-strdup-s01
Open

prownd wants to merge 1 commit into
rsyslog:mainfrom
prownd:tokener-validate-depth-and-printbuf-guard-key-strdup-s01

Conversation

@prownd

@prownd prownd commented Sep 15, 2026

Copy link
Copy Markdown
  • fjson_tokener_new_ex() rejected no depth check: depth <= 0 called calloc(0, ...) and fjson_tokener_reset() then wrote stack[0], a heap buffer overflow. Reject depth < 1 up front.
  • fjson_tokener_new_ex() ignored a printbuf_new() failure, leaving tok->pb == NULL to be dereferenced during parsing. Check it and clean up on failure.
  • the object-key strdup() failure was unchecked; a NULL key is later treated as an empty slot and also passed to strcmp(). Bail out with an error instead.

Summary by cubic

Hardens tokener initialization and object-key parsing against allocation failures. fjson_tokener_new_ex() now rejects depths below 1 and cleans up when printbuf_new() fails, while parsing aborts with an error if duplicating an object key fails instead of continuing with a NULL key.

Written for commit 8db922e. Summary will update on new commits.

Review in cubic

- fjson_tokener_new_ex() rejected no depth check: depth <= 0 called
  calloc(0, ...) and fjson_tokener_reset() then wrote stack[0], a heap
  buffer overflow. Reject depth < 1 up front.
- fjson_tokener_new_ex() ignored a printbuf_new() failure, leaving
  tok->pb == NULL to be dereferenced during parsing. Check it and clean
  up on failure.
- the object-key strdup() failure was unchecked; a NULL key is later
  treated as an empty slot and also passed to strcmp(). Bail out with an
  error instead.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

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.

Re-trigger cubic

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.

1 participant