From 6c89ebf64b496ae68f86bef1136818b38fce9591 Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Khan Date: Fri, 22 Nov 2024 15:32:50 -0800 Subject: [PATCH] guard against Int64 max --- Source/AwsCommonRuntimeKit/crt/CBOR.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Source/AwsCommonRuntimeKit/crt/CBOR.swift b/Source/AwsCommonRuntimeKit/crt/CBOR.swift index f514f4e9..a10695ff 100644 --- a/Source/AwsCommonRuntimeKit/crt/CBOR.swift +++ b/Source/AwsCommonRuntimeKit/crt/CBOR.swift @@ -177,6 +177,9 @@ public class CBORDecoder { else { throw CommonRunTimeError.crtError(.makeFromLastError()) } + guard out_value <= Int64.max else { + throw CommonRunTimeError.crtError(CRTError(code: AWS_ERROR_CBOR_UNEXPECTED_TYPE.rawValue)) + } return .int(Int64(-Int64(out_value) - 1)) } case AWS_CBOR_TYPE_FLOAT: