1
0
mirror of https://github.com/ARMmbed/mbedtls.git synced 2025-05-13 02:14:40 +08:00

Refactor macro-spanning if in asn1write.c

Signed-off-by: David Horstmann <david.horstmann@arm.com>
This commit is contained in:
David Horstmann 2022-10-06 18:57:57 +01:00
parent 2788f6b668
commit 8a7629fd0f

View File

@ -78,9 +78,11 @@ int mbedtls_asn1_write_len( unsigned char **p, const unsigned char *start, size_
return( 4 ); return( 4 );
} }
int len_valid = 1;
#if SIZE_MAX > 0xFFFFFFFF #if SIZE_MAX > 0xFFFFFFFF
if( len <= 0xFFFFFFFF ) len_valid = ( len <= 0xFFFFFFFF );
#endif #endif
if( len_valid )
{ {
if( *p - start < 5 ) if( *p - start < 5 )
return( MBEDTLS_ERR_ASN1_BUF_TOO_SMALL ); return( MBEDTLS_ERR_ASN1_BUF_TOO_SMALL );
@ -92,10 +94,10 @@ int mbedtls_asn1_write_len( unsigned char **p, const unsigned char *start, size_
*--(*p) = 0x84; *--(*p) = 0x84;
return( 5 ); return( 5 );
} }
else
#if SIZE_MAX > 0xFFFFFFFF {
return( MBEDTLS_ERR_ASN1_INVALID_LENGTH ); return( MBEDTLS_ERR_ASN1_INVALID_LENGTH );
#endif }
} }
int mbedtls_asn1_write_tag( unsigned char **p, const unsigned char *start, unsigned char tag ) int mbedtls_asn1_write_tag( unsigned char **p, const unsigned char *start, unsigned char tag )