Skip to content

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

Open
grooverdan wants to merge 1 commit intoMariaDB:10.6from
grooverdan:MDEV-39213
Open

MDEV-35548: Fix out-of-bounds array access in json_get_path_start#5013
grooverdan wants to merge 1 commit intoMariaDB:10.6from
grooverdan:MDEV-39213

Conversation

@grooverdan
Copy link
Copy Markdown
Member

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.

Backport to 10.6 of commit 4f54689.

Additional test case from Rucha Deodhar

@grooverdan grooverdan added the MariaDB Foundation Pull requests created by MariaDB Foundation label Apr 29, 2026
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.

Backport to 10.6 of commit 4f54689.

Additional test case from Rucha Deodhar

Signed-off-by: Varun Deep Saini <varun.23bcs10048@ms.sst.scaler.com>
Signed-off-by: Varun Deep Saini <deepsainivarun@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

MariaDB Foundation Pull requests created by MariaDB Foundation

Development

Successfully merging this pull request may close these issues.

4 participants