mirror of
				https://github.com/open-source-parsers/jsoncpp.git
				synced 2025-11-04 12:17:36 +01:00 
			
		
		
		
	Made two security fixes.
This commit is contained in:
		@@ -611,6 +611,11 @@ Reader::decodeDouble( Token &token )
 | 
			
		||||
   int count;
 | 
			
		||||
   int length = int(token.end_ - token.start_);
 | 
			
		||||
 | 
			
		||||
   // Sanity check to avoid buffer overflow exploits.
 | 
			
		||||
   if (length < 0) {
 | 
			
		||||
      return addError( "Unable to parse token length", token );
 | 
			
		||||
   }
 | 
			
		||||
 | 
			
		||||
   // Avoid using a string constant for the format control string given to
 | 
			
		||||
   // sscanf, as this can cause hard to debug crashes on OS X. See here for more
 | 
			
		||||
   // info:
 | 
			
		||||
 
 | 
			
		||||
@@ -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