mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-10-23 10:28:11 +08:00
Made two security fixes.
This commit is contained in:
@@ -56,6 +56,12 @@ duplicateStringValue( const char *value,
|
||||
{
|
||||
if ( length == unknown )
|
||||
length = (unsigned int)strlen(value);
|
||||
|
||||
// Avoid an integer overflow in the call to malloc below by limiting length
|
||||
// to a sane value.
|
||||
if (length >= (unsigned)Value::maxInt)
|
||||
length = Value::maxInt - 1;
|
||||
|
||||
char *newString = static_cast<char *>( malloc( length + 1 ) );
|
||||
JSON_ASSERT_MESSAGE( newString != 0, "Failed to allocate string value buffer" );
|
||||
memcpy( newString, value, length );
|
||||
|
Reference in New Issue
Block a user