MDEV-35548: Fix out-of-bounds array access in json_get_path_start#4739
Open
varundeepsaini wants to merge 1 commit intoMariaDB:10.6from
Open
MDEV-35548: Fix out-of-bounds array access in json_get_path_start#4739varundeepsaini wants to merge 1 commit intoMariaDB:10.6from
varundeepsaini wants to merge 1 commit intoMariaDB:10.6from
Conversation
gkodinov
requested changes
Mar 6, 2026
Member
gkodinov
left a comment
There was a problem hiding this comment.
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.
6ba4bd2 to
443c272
Compare
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>
443c272 to
1232fca
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
json_get_path_start()setp->last_steptop->steps - 1, creating a pointer before the beginning of thesteps[]array. This is undefined behavior flagged by UBSAN asindex -1 out of bounds for type 'json_path_step_t[32]'.NULLas the sentinel value instead, and check forNULLinjson_get_path_next()rather than comparing againstp->steps.