summaryrefslogtreecommitdiff
path: root/vendor/github.com/json-iterator/go/iter.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-11-07 18:49:19 +0100
committerGitHub <noreply@github.com>2019-11-07 18:49:19 +0100
commit347499778cb1a7045dc831f99b9539bc20fe008d (patch)
treec31cde0f384a912fa950136ddb0797c631c81e90 /vendor/github.com/json-iterator/go/iter.go
parent20c8a01af192db69264aa44f46193552206fa427 (diff)
parentd55734e69bcb645802b33ef703d336b89bbeefe1 (diff)
downloadpodman-347499778cb1a7045dc831f99b9539bc20fe008d.tar.gz
podman-347499778cb1a7045dc831f99b9539bc20fe008d.tar.bz2
podman-347499778cb1a7045dc831f99b9539bc20fe008d.zip
Merge pull request #4378 from containers/dependabot/go_modules/github.com/json-iterator/go-1.1.8
Bump github.com/json-iterator/go from 1.1.7 to 1.1.8
Diffstat (limited to 'vendor/github.com/json-iterator/go/iter.go')
-rw-r--r--vendor/github.com/json-iterator/go/iter.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/vendor/github.com/json-iterator/go/iter.go b/vendor/github.com/json-iterator/go/iter.go
index 95ae54fbf..29b31cf78 100644
--- a/vendor/github.com/json-iterator/go/iter.go
+++ b/vendor/github.com/json-iterator/go/iter.go
@@ -74,6 +74,7 @@ type Iterator struct {
buf []byte
head int
tail int
+ depth int
captureStartedAt int
captured []byte
Error error
@@ -88,6 +89,7 @@ func NewIterator(cfg API) *Iterator {
buf: nil,
head: 0,
tail: 0,
+ depth: 0,
}
}
@@ -99,6 +101,7 @@ func Parse(cfg API, reader io.Reader, bufSize int) *Iterator {
buf: make([]byte, bufSize),
head: 0,
tail: 0,
+ depth: 0,
}
}
@@ -110,6 +113,7 @@ func ParseBytes(cfg API, input []byte) *Iterator {
buf: input,
head: 0,
tail: len(input),
+ depth: 0,
}
}
@@ -128,6 +132,7 @@ func (iter *Iterator) Reset(reader io.Reader) *Iterator {
iter.reader = reader
iter.head = 0
iter.tail = 0
+ iter.depth = 0
return iter
}
@@ -137,6 +142,7 @@ func (iter *Iterator) ResetBytes(input []byte) *Iterator {
iter.buf = input
iter.head = 0
iter.tail = len(input)
+ iter.depth = 0
return iter
}
@@ -320,3 +326,24 @@ func (iter *Iterator) Read() interface{} {
return nil
}
}
+
+// limit maximum depth of nesting, as allowed by https://tools.ietf.org/html/rfc7159#section-9
+const maxDepth = 10000
+
+func (iter *Iterator) incrementDepth() (success bool) {
+ iter.depth++
+ if iter.depth <= maxDepth {
+ return true
+ }
+ iter.ReportError("incrementDepth", "exceeded max depth")
+ return false
+}
+
+func (iter *Iterator) decrementDepth() (success bool) {
+ iter.depth--
+ if iter.depth >= 0 {
+ return true
+ }
+ iter.ReportError("decrementDepth", "unexpected negative nesting")
+ return false
+}