From f0c66765d7a38c89176d5a8e41de20f79578cf53 Mon Sep 17 00:00:00 2001 From: juanvallejo Date: Tue, 11 Jul 2017 15:10:19 -0400 Subject: [PATCH] check for negative index values Kubernetes-commit: 113ff3bb9854d6c5c4e8d1a66749075c480130a9 --- util/jsonpath/jsonpath.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/jsonpath/jsonpath.go b/util/jsonpath/jsonpath.go index dda5bdef..cc2fbb2a 100644 --- a/util/jsonpath/jsonpath.go +++ b/util/jsonpath/jsonpath.go @@ -259,10 +259,10 @@ func (j *JSONPath) evalArray(input []reflect.Value, node *ArrayNode) ([]reflect. sliceLength := value.Len() 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) } - 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) } }