Repository navigation
Conversation
cJSONUtils_ApplyPatches{,CaseSensitive} applied operations directly to
the caller's document and returned on the first failure, leaving
earlier operations applied: an attacker-supplied patch could destroy
data and then fail validation. Run all operations against a duplicate
and commit to the original only when every operation succeeds, keeping
the caller's pointer stable. Working from duplicates also closes the
use-after-free when the patch array itself lives inside the patched
document. Add regression tests for rollback and success paths.
Replace the stale NOT-atomic advisory comment: cJSONUtils_ApplyPatches and cJSONUtils_ApplyPatchesCaseSensitive are now atomic (all-or-nothing). Returns-0-for-success contract is unchanged.
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.
Apply each JSON Patch array to duplicates and commit only after every operation succeeds. Failed patches leave the original document untouched, the caller's pointer stays stable, and patch arrays stored inside the document remain valid during iteration.
Preserve the target's next/prev links when committing a successful patch to a non-root node. Regression cases cover the first, middle and last child in both objects and arrays through both ApplyPatches entry points.
Validation at 1e48286:
Behavior change: failed patch arrays now leave the document unchanged instead of keeping earlier operations applied. Error status codes are unchanged. Duplicating the document and patch array increases memory use and execution time.
AI assistance: This report and patch were prepared with AI assistance. Validation commands and results are recorded above.