Avoid in-out length in base64

This commit is contained in:
Manuel Pégourié-Gonnard 2015-06-02 16:30:35 +01:00
parent 3335205a21
commit ba56136b5c
6 changed files with 41 additions and 45 deletions

View file

@ -96,14 +96,14 @@ int convert_pem_to_der( const unsigned char *input, size_t ilen,
if( s2 <= s1 || s2 > end )
return( -1 );
ret = mbedtls_base64_decode( NULL, &len, (const unsigned char *) s1, s2 - s1 );
ret = mbedtls_base64_decode( NULL, 0, &len, (const unsigned char *) s1, s2 - s1 );
if( ret == MBEDTLS_ERR_BASE64_INVALID_CHARACTER )
return( ret );
if( len > *olen )
return( -1 );
if( ( ret = mbedtls_base64_decode( output, &len, (const unsigned char *) s1,
if( ( ret = mbedtls_base64_decode( output, len, &len, (const unsigned char *) s1,
s2 - s1 ) ) != 0 )
{
return( ret );