From 9f8dd8cff8abc294b2c46af80c77788a73416ebf Mon Sep 17 00:00:00 2001 From: Matthias Andree Date: Sat, 1 Jul 2023 13:41:26 +0200 Subject: [PATCH] Fix XMPUtils::ConvertToInt64 sscanf() type This function uses sscanf() with "%lld" or "%llx" to parse a string to an integer. However, nothing guarantees that sizeof(XMP_Int64) == sizeof(long long); the latter is what sscanf will fill with either of these format strings, to avoid memory corruption. Use a long long to match the sscanf size, and let the return statement cast it to XMP_Int64. --- xmpsdk/src/XMPUtils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xmpsdk/src/XMPUtils.cpp b/xmpsdk/src/XMPUtils.cpp index 89afd3d62d..9f9ec0bb15 100644 --- a/xmpsdk/src/XMPUtils.cpp +++ b/xmpsdk/src/XMPUtils.cpp @@ -1215,7 +1215,7 @@ XMPUtils::ConvertToInt64 ( XMP_StringPtr strValue ) int count; char nextCh; - XMP_Int64 result; + long long result; if ( ! XMP_LitNMatch ( strValue, "0x", 2 ) ) { count = sscanf ( strValue, "%lld%c", &result, &nextCh );