Skip to content

fix: add overflow check in decode_array_index_from_pointer()#1002

Open
SummerSolsticeMuch wants to merge 1 commit intoDaveGamble:masterfrom
SummerSolsticeMuch:fix/decode-array-index-overflow
Open

fix: add overflow check in decode_array_index_from_pointer()#1002
SummerSolsticeMuch wants to merge 1 commit intoDaveGamble:masterfrom
SummerSolsticeMuch:fix/decode-array-index-overflow

Conversation

@SummerSolsticeMuch
Copy link
Copy Markdown

Summary

  • Add integer overflow detection in decode_array_index_from_pointer()

The function parses a decimal string into size_t via parsed_index = (10 * parsed_index) + digit with no overflow check. A crafted large numeric string (e.g. "18446744073709551617") silently wraps around size_t, potentially resolving to an unintended small array index in JSON Patch operations.

Test plan

  • Apply a JSON Patch with path /arr/18446744073709551617 — should fail instead of wrapping to a small index
  • Normal small indices still work correctly

The function parses a decimal string into size_t with no overflow
detection. A very large numeric string (e.g. "18446744073709551617")
silently wraps around, potentially resolving to an unintended small
array index.

Add an overflow guard before the multiply-and-add so that indices
exceeding SIZE_MAX are rejected instead of wrapping.
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