mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-03-29 04:20:12 +00:00
Make x509_string_cmp() iterative
This commit is contained in:
parent
8a5e3d4a40
commit
f631bbc1da
@ -1636,25 +1636,30 @@ static int x509_string_cmp( const x509_buf *a, const x509_buf *b )
|
|||||||
*/
|
*/
|
||||||
static int x509_name_cmp( const x509_name *a, const x509_name *b )
|
static int x509_name_cmp( const x509_name *a, const x509_name *b )
|
||||||
{
|
{
|
||||||
if( a == NULL && b == NULL )
|
/* Avoid recursion, it might not be optimised by the compiler */
|
||||||
return( 0 );
|
while( a != NULL || b != NULL )
|
||||||
|
|
||||||
if( a == NULL || b == NULL )
|
|
||||||
return( -1 );
|
|
||||||
|
|
||||||
/* type */
|
|
||||||
if( a->oid.tag != b->oid.tag ||
|
|
||||||
a->oid.len != b->oid.len ||
|
|
||||||
memcmp( a->oid.p, b->oid.p, b->oid.len ) != 0 )
|
|
||||||
{
|
{
|
||||||
return( -1 );
|
if( a == NULL || b == NULL )
|
||||||
|
return( -1 );
|
||||||
|
|
||||||
|
/* type */
|
||||||
|
if( a->oid.tag != b->oid.tag ||
|
||||||
|
a->oid.len != b->oid.len ||
|
||||||
|
memcmp( a->oid.p, b->oid.p, b->oid.len ) != 0 )
|
||||||
|
{
|
||||||
|
return( -1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* value */
|
||||||
|
if( x509_string_cmp( &a->val, &b->val ) != 0 )
|
||||||
|
return( -1 );
|
||||||
|
|
||||||
|
a = a->next;
|
||||||
|
b = b->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* value */
|
/* a == NULL == b */
|
||||||
if( x509_string_cmp( &a->val, &b->val ) != 0 )
|
return( 0 );
|
||||||
return( -1 );
|
|
||||||
|
|
||||||
return( x509_name_cmp( a->next, b->next ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user