Merge pull request #3815 from nspcc-dev/max-cond-nest

This commit is contained in:
Roman Khimov 2025-02-17 15:45:17 +03:00 committed by GitHub
commit 0d8c751e50
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -37,7 +37,7 @@ const (
WitnessCalledByGroup WitnessConditionType = 0x29 // CalledByGroup
// MaxConditionNesting limits the maximum allowed level of condition nesting.
MaxConditionNesting = 2
MaxConditionNesting = 3
)
// WitnessCondition is a condition of WitnessRule.
@ -564,7 +564,7 @@ func DecodeBinaryCondition(r *io.BinReader) WitnessCondition {
}
func decodeBinaryCondition(r *io.BinReader, maxDepth int) WitnessCondition {
if maxDepth < 0 {
if maxDepth <= 0 {
r.Err = errors.New("too many nesting levels")
return nil
}
@ -629,7 +629,7 @@ func UnmarshalConditionJSON(data []byte) (WitnessCondition, error) {
}
func unmarshalConditionJSON(data []byte, maxDepth int) (WitnessCondition, error) {
if maxDepth < 0 {
if maxDepth <= 0 {
return nil, errors.New("too many nesting levels")
}
aux := &conditionAux{}