Repository navigation
config: preserve entry ownership when list append fails - #7469
Open
LittleNewton wants to merge 1 commit into
Open
LittleNewton wants to merge 1 commit into
LittleNewton wants to merge 1 commit into
Conversation
Allocate the list node before mutating the map or sharing multivar names. Check map-head allocation and release temporary nodes when insertion fails, so an unsuccessful append leaves the entry owned by its caller. Release rejected entries in the file and memory configuration backends. Add allocation-failure sweeps that verify unchanged contents and ownership, retrying the same entry, and destruction for new keys, map growth and multivars. Wrap the active allocator to support strict allocator builds. This overlaps the append fix in libgit2#7429, with focused ownership and retry tests and cleanup in both configuration backends. Credit the existing report and fix; this does not claim first discovery. Fixes libgit2#7416.
This branch has not been deployed
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.
An allocation failure in
git_config_list_append()can insert a NULL map head and then dereference it. Other failures can leak the new map head or modify the map and a multivar entry's name before the list node is allocated. A caller cannot reliably clean up or retry the rejected entry in that state.Allocate the list node first, check the map-head allocation, and release temporary nodes if map insertion fails. After any append failure, the caller still owns an unchanged entry and existing configuration entries retain their values and multivar status. Document this internal ownership contract and release rejected entries in the file and memory configuration backends.
Add three focused allocation-failure sweeps for an empty list, hash-map growth, and multivar append. Each verifies the error, unchanged entry ownership and existing contents, successful retry of the same entry, and list destruction. The allocator delegates to the active allocator, including
DEBUG_STRICT_ALLOCbuilds.Fixes #7416. Related to #7429: its existing fix already addresses the unchecked allocation and allocation ordering. This is an overlapping, append-focused alternative with explicit ownership/retry regressions and cleanup in both configuration backends; it does not claim first discovery or supersede that PR's broader fixes (including #7417). Thank you to the original reporter and the author of #7429.
Validation
Tested on Linux x86_64 against
42a89d7cc9374a19e72fa57011e5fe3a99c7b3bf:config_list.c:178.-sconfigsuite passes with AddressSanitizer and separately withDEBUG_STRICT_ALLOC=ON: 157 passed, 1 skipped in each build. Builds useENABLE_WERROR=ON.core::structinit::compare(padding-byte comparison). The same test fails in a complete offline run of unmodified upstream.path::core::validate_current_user_ownership. The same failure reproduces on unmodified upstream in this container.ASAN_OPTIONS=detect_leaks=0:abort_on_error=1; no successful leak-check run is claimed.Focused regression command: