summaryrefslogtreecommitdiffstats
path: root/vendor/google.golang.org/protobuf/encoding
diff options
context:
space:
mode:
authorWim <wim@42.be>2022-04-12 00:30:21 +0200
committerGitHub <noreply@github.com>2022-04-12 00:30:21 +0200
commit281ef53e7de5d30114dbf57a4b506b2d8d2720cc (patch)
tree5fe13b85ffe312053452e0d7107ca4b174a412e0 /vendor/google.golang.org/protobuf/encoding
parentf044b948e257814e8e1f70d4b66821bfd9c2ff06 (diff)
downloadmatterbridge-msglm-281ef53e7de5d30114dbf57a4b506b2d8d2720cc.tar.gz
matterbridge-msglm-281ef53e7de5d30114dbf57a4b506b2d8d2720cc.tar.bz2
matterbridge-msglm-281ef53e7de5d30114dbf57a4b506b2d8d2720cc.zip
Update dependencies (#1800)
Diffstat (limited to 'vendor/google.golang.org/protobuf/encoding')
-rw-r--r--vendor/google.golang.org/protobuf/encoding/protowire/wire.go19
1 files changed, 14 insertions, 5 deletions
diff --git a/vendor/google.golang.org/protobuf/encoding/protowire/wire.go b/vendor/google.golang.org/protobuf/encoding/protowire/wire.go
index a427f8b7..9c61112f 100644
--- a/vendor/google.golang.org/protobuf/encoding/protowire/wire.go
+++ b/vendor/google.golang.org/protobuf/encoding/protowire/wire.go
@@ -21,10 +21,11 @@ import (
type Number int32
const (
- MinValidNumber Number = 1
- FirstReservedNumber Number = 19000
- LastReservedNumber Number = 19999
- MaxValidNumber Number = 1<<29 - 1
+ MinValidNumber Number = 1
+ FirstReservedNumber Number = 19000
+ LastReservedNumber Number = 19999
+ MaxValidNumber Number = 1<<29 - 1
+ DefaultRecursionLimit = 10000
)
// IsValid reports whether the field number is semantically valid.
@@ -55,6 +56,7 @@ const (
errCodeOverflow
errCodeReserved
errCodeEndGroup
+ errCodeRecursionDepth
)
var (
@@ -112,6 +114,10 @@ func ConsumeField(b []byte) (Number, Type, int) {
// When parsing a group, the length includes the end group marker and
// the end group is verified to match the starting field number.
func ConsumeFieldValue(num Number, typ Type, b []byte) (n int) {
+ return consumeFieldValueD(num, typ, b, DefaultRecursionLimit)
+}
+
+func consumeFieldValueD(num Number, typ Type, b []byte, depth int) (n int) {
switch typ {
case VarintType:
_, n = ConsumeVarint(b)
@@ -126,6 +132,9 @@ func ConsumeFieldValue(num Number, typ Type, b []byte) (n int) {
_, n = ConsumeBytes(b)
return n
case StartGroupType:
+ if depth < 0 {
+ return errCodeRecursionDepth
+ }
n0 := len(b)
for {
num2, typ2, n := ConsumeTag(b)
@@ -140,7 +149,7 @@ func ConsumeFieldValue(num Number, typ Type, b []byte) (n int) {
return n0 - len(b)
}
- n = ConsumeFieldValue(num2, typ2, b)
+ n = consumeFieldValueD(num2, typ2, b, depth-1)
if n < 0 {
return n // forward error code
}