mirror of
https://git.suyu.dev/suyu/mbedtls.git
synced 2025-12-24 00:06:32 +01:00
Minor optimizations (original by Peter Vaskovic, modified by Paul Bakker)
Move strlen out of for loop. Remove redundant null checks before free.
This commit is contained in:
parent
8ebfe084ab
commit
14b16c62e9
4 changed files with 9 additions and 12 deletions
|
|
@ -1550,12 +1550,12 @@ static int x509_name_cmp( const void *s1, const void *s2, size_t len )
|
|||
static int x509_wildcard_verify( const char *cn, x509_buf *name )
|
||||
{
|
||||
size_t i;
|
||||
size_t cn_idx = 0;
|
||||
size_t cn_idx = 0, cn_len = strlen( cn );
|
||||
|
||||
if( name->len < 3 || name->p[0] != '*' || name->p[1] != '.' )
|
||||
return( 0 );
|
||||
|
||||
for( i = 0; i < strlen( cn ); ++i )
|
||||
for( i = 0; i < cn_len; ++i )
|
||||
{
|
||||
if( cn[i] == '.' )
|
||||
{
|
||||
|
|
@ -1567,7 +1567,7 @@ static int x509_wildcard_verify( const char *cn, x509_buf *name )
|
|||
if( cn_idx == 0 )
|
||||
return( 0 );
|
||||
|
||||
if( strlen( cn ) - cn_idx == name->len - 1 &&
|
||||
if( cn_len - cn_idx == name->len - 1 &&
|
||||
x509_name_cmp( name->p + 1, cn + cn_idx, name->len - 1 ) == 0 )
|
||||
{
|
||||
return( 1 );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue