Skip to content

Commit

Permalink
Fix XMPUtils::ConvertToInt64 sscanf() type
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mandree committed Jul 1, 2023
1 parent 6156349 commit 9f8dd8c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion xmpsdk/src/XMPUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down

0 comments on commit 9f8dd8c

Please sign in to comment.