mirror of
				https://github.com/Mbed-TLS/mbedtls.git
				synced 2025-11-03 20:33:16 +03:00 
			
		
		
		
	Merge pull request #6066 from AndrzejKurek/fix-some-resource-leaks-2-28
Fix `mbedtls_pk_parse_public_key` resource leaks
This commit is contained in:
		
							
								
								
									
										4
									
								
								ChangeLog.d/fix_some_resource_leaks.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								ChangeLog.d/fix_some_resource_leaks.txt
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,4 @@
 | 
			
		||||
Bugfix
 | 
			
		||||
   * Fix resource leaks in mbedtls_pk_parse_public_key() in low
 | 
			
		||||
     memory conditions.
 | 
			
		||||
 | 
			
		||||
@@ -1463,10 +1463,16 @@ int mbedtls_pk_parse_public_key( mbedtls_pk_context *ctx,
 | 
			
		||||
    {
 | 
			
		||||
        p = pem.buf;
 | 
			
		||||
        if( ( pk_info = mbedtls_pk_info_from_type( MBEDTLS_PK_RSA ) ) == NULL )
 | 
			
		||||
        {
 | 
			
		||||
            mbedtls_pem_free( &pem );
 | 
			
		||||
            return( MBEDTLS_ERR_PK_UNKNOWN_PK_ALG );
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if( ( ret = mbedtls_pk_setup( ctx, pk_info ) ) != 0 )
 | 
			
		||||
        {
 | 
			
		||||
            mbedtls_pem_free( &pem );
 | 
			
		||||
            return( ret );
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if ( ( ret = pk_get_rsapubkey( &p, p + pem.buflen, mbedtls_pk_rsa( *ctx ) ) ) != 0 )
 | 
			
		||||
            mbedtls_pk_free( ctx );
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user