Co-authored-by: haiyizxx <haiyizxx@gmail.com> Co-authored-by: Julien Robert <julien@rbrt.fr>
This commit is contained in:
co-authored by
haiyizxx
Julien Robert
parent
8e710b7efc
commit
92af502815
@@ -274,10 +274,10 @@ func (r statefulUnpacker) cloneForRecursion() *statefulUnpacker {
|
||||
// UnpackAny deserializes a protobuf Any message into the provided interface, ensuring the interface is a pointer.
|
||||
// It applies stateful constraints such as max depth and call limits, and unpacks interfaces if required.
|
||||
func (r *statefulUnpacker) UnpackAny(any *Any, iface interface{}) error {
|
||||
if r.maxDepth == 0 {
|
||||
if r.maxDepth <= 0 {
|
||||
return errors.New("max depth exceeded")
|
||||
}
|
||||
if r.maxCalls.count == 0 {
|
||||
if r.maxCalls.count <= 0 {
|
||||
return errors.New("call limit exceeded")
|
||||
}
|
||||
// here we gracefully handle the case in which `any` itself is `nil`, which may occur in message decoding
|
||||
|
||||
@@ -54,7 +54,7 @@ func doRejectUnknownFields(
|
||||
if len(bz) == 0 {
|
||||
return hasUnknownNonCriticals, nil
|
||||
}
|
||||
if recursionLimit == 0 {
|
||||
if recursionLimit <= 0 {
|
||||
return false, errors.New("recursion limit reached")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user