diff --git a/Sources/CBORDecoder.swift b/Sources/CBORDecoder.swift index 4e26806..8455ded 100644 --- a/Sources/CBORDecoder.swift +++ b/Sources/CBORDecoder.swift @@ -60,9 +60,16 @@ public class CBORDecoder { throw CBORError.tooLongSequence } + /// Application-safe limit here + let MAX_REASONABLE_LENGTH = 200_000 + guard n <= MAX_REASONABLE_LENGTH else { + throw CBORError.tooLongSequence + } + return Int(n) } + private func readN(_ n: Int) throws -> [CBOR] { return try (0..