mirror of
https://github.com/kubernetes/client-go.git
synced 2025-07-06 03:36:26 +00:00
check for negative index values
Kubernetes-commit: 113ff3bb9854d6c5c4e8d1a66749075c480130a9
This commit is contained in:
parent
517feb7802
commit
f0c66765d7
@ -259,10 +259,10 @@ func (j *JSONPath) evalArray(input []reflect.Value, node *ArrayNode) ([]reflect.
|
|||||||
|
|
||||||
sliceLength := value.Len()
|
sliceLength := value.Len()
|
||||||
if params[1].Value != params[0].Value { // if you're requesting zero elements, allow it through.
|
if params[1].Value != params[0].Value { // if you're requesting zero elements, allow it through.
|
||||||
if params[0].Value >= sliceLength {
|
if params[0].Value >= sliceLength || params[0].Value < 0 {
|
||||||
return input, fmt.Errorf("array index out of bounds: index %d, length %d", params[0].Value, sliceLength)
|
return input, fmt.Errorf("array index out of bounds: index %d, length %d", params[0].Value, sliceLength)
|
||||||
}
|
}
|
||||||
if params[1].Value > sliceLength {
|
if params[1].Value > sliceLength || params[1].Value < 0 {
|
||||||
return input, fmt.Errorf("array index out of bounds: index %d, length %d", params[1].Value-1, sliceLength)
|
return input, fmt.Errorf("array index out of bounds: index %d, length %d", params[1].Value-1, sliceLength)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user