Skip to content
/ server Public

MDEV-35548: Fix out-of-bounds array access in json_get_path_start#4739

Open
varundeepsaini wants to merge 1 commit intoMariaDB:10.6from
varundeepsaini:MDEV-35548-out-of-bounds-fix
Open

MDEV-35548: Fix out-of-bounds array access in json_get_path_start#4739
varundeepsaini wants to merge 1 commit intoMariaDB:10.6from
varundeepsaini:MDEV-35548-out-of-bounds-fix

Conversation

@varundeepsaini
Copy link
Contributor

@varundeepsaini varundeepsaini commented Mar 5, 2026

Summary

  • json_get_path_start() set p->last_step to p->steps - 1, creating a pointer before the beginning of the steps[] array. This is undefined behavior flagged by UBSAN as index -1 out of bounds for type 'json_path_step_t[32]'.
  • Use NULL as the sentinel value instead, and check for NULL in json_get_path_next() rather than comparing against p->steps.

@gkodinov gkodinov added the External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements. label Mar 6, 2026
Copy link
Member

@gkodinov gkodinov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution! This is a preliminary review.

The fix itself looks good.

Please add test cases that cover the two queries that are mentioned in the jira.

@varundeepsaini varundeepsaini force-pushed the MDEV-35548-out-of-bounds-fix branch 2 times, most recently from 6ba4bd2 to 443c272 Compare March 6, 2026 16:28
json_get_path_start() set p->last_step to p->steps - 1, creating a
pointer before the beginning of the steps[] array. This is undefined
behavior flagged by UBSAN as "index -1 out of bounds for type
json_path_step_t[32]".

Use NULL as the sentinel value instead, and check for NULL in
json_get_path_next() rather than comparing against p->steps.

Signed-off-by: Varun Deep Saini <varun.23bcs10048@ms.sst.scaler.com>
@varundeepsaini varundeepsaini force-pushed the MDEV-35548-out-of-bounds-fix branch from 443c272 to 1232fca Compare March 6, 2026 16:33
@varundeepsaini varundeepsaini requested a review from gkodinov March 6, 2026 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements.

Development

Successfully merging this pull request may close these issues.

2 participants