From a7ca25a181f92bc4d4db75f4994939f5cbd1d788 Mon Sep 17 00:00:00 2001 From: Andrei Homescu Date: Fri, 2 Apr 2021 23:14:02 -0700 Subject: Fix integer cast in handleNint This fixes an incorrect integer cast in the handleNint function in cppbor_parse.cpp which would trigger UBSAN failures in the Trusty apploader. Change-Id: Id35865e524c9837d907fe352feac783b3f7f36b0 --- src/cppbor_parse.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cppbor_parse.cpp b/src/cppbor_parse.cpp index ab01ee7..f5e8fcf 100644 --- a/src/cppbor_parse.cpp +++ b/src/cppbor_parse.cpp @@ -71,7 +71,7 @@ std::tuple handleNint(uint64_t value, const uint8_ parseClient->error(hdrBegin, "NINT values that don't fit in int64_t are not supported."); return {hdrBegin, nullptr /* end parsing */}; } - std::unique_ptr item = std::make_unique(-1 - static_cast(value)); + std::unique_ptr item = std::make_unique(-1 - static_cast(value)); return {hdrEnd, parseClient->item(item, hdrBegin, hdrEnd /* valueBegin */, hdrEnd /* itemEnd */)}; } -- cgit v1.2.3