Repository navigation
fix: reject out-of-range list indexes in --state-values-set - #2887
Merged
yxxhero merged 1 commit intoNov 11, 2026
Merged
Conversation
A negative index such as foo[-1]=x panicked with index out of range, and a very large one tried to allocate the whole list. Set now validates every index before changing the map, with the same 65536 limit as Helm's --set, and both flags report the error. Signed-off-by: Lucas Barros <[email protected]>
lbarrosby
requested review from
aditmeno,
itscaro,
mumoshu,
xiaomudk,
yxxhero and
zhaque44
as code owners
November 10, 2026 10:22
yxxhero
approved these changes
Nov 11, 2026
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.
--state-values-setand--state-values-set-stringcrash on a negative list index such asservers[-1].host=a. Both end inmaputil.Set, which panics:(
Set(m, ParseKey("foo[-1]"), "x", false)onmain.)getCursorparses[-1]as index -1 andindexedKeyArg.getArraythen indexes the slice with it. A large index such asservers[100000000000]=agoes the other way and makesgetArrayallocate a slice of that length.setAssignmentwas added to return errors instead of panicking on malformed assignments, butmaputil.Sethad no way to report this case.Changes:
maputil.Setnow returns an error. It checks every key segment first and rejects an index below 0 or abovemaputil.MaxIndex(65536, the same limit and wording as Helm'sstrvalsfor--set), so the map is not left half-updated.parseStateValuesSet/parseStateValuesSetStringwrap that error as--state-values-set: invalid assignment "<assignment>": ..., the format used for the other malformed-assignment errors.Tests:
pkg/maputil:TestSet_RejectsOutOfRangeIndex(negative index at the first and a nested segment, index above the limit; map unchanged) andTestSet_AcceptsMaxIndex. ExistingSetcalls in the tests now check the returned error.pkg/config: new cases inTestNewCLIConfigImplStateValuesSetandTestNewCLIConfigImplStateValuesSetString.