mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-01-11 12:25:37 +00:00
Determine whether CRT is initialized or not through raw data pointer
Previously, `mbedtls_x509_crt_der_internal()` used the `version` field (which is `0` after initialization but strictly greater than 0 once a CRT has successfully been parsed) to determine whether an `mbedtls_x509_crt` instance had already been setup. Preparating for the removal of `version` from the structure, this commit modifies the code to instead peek at the raw data pointer, which is NULL as long as the CRT structure hasn't been setup with a CRT, and will be kept in the new CRT structure.
This commit is contained in:
parent
4f869eda64
commit
371e0e4573
|
@ -2955,7 +2955,7 @@ static int ssl_write_certificate_request( mbedtls_ssl_context *ssl )
|
|||
#endif
|
||||
crt = ssl->conf->ca_chain;
|
||||
|
||||
while( crt != NULL && crt->version != 0 )
|
||||
while( crt != NULL && crt->raw.p != NULL )
|
||||
{
|
||||
dn_size = crt->subject_raw.len;
|
||||
|
||||
|
|
|
@ -1321,7 +1321,7 @@ static int mbedtls_x509_crt_parse_der_internal( mbedtls_x509_crt *chain,
|
|||
if( crt == NULL || buf == NULL )
|
||||
return( MBEDTLS_ERR_X509_BAD_INPUT_DATA );
|
||||
|
||||
while( crt->version != 0 && crt->next != NULL )
|
||||
while( crt->raw.p != NULL && crt->next != NULL )
|
||||
{
|
||||
prev = crt;
|
||||
crt = crt->next;
|
||||
|
@ -1330,7 +1330,7 @@ static int mbedtls_x509_crt_parse_der_internal( mbedtls_x509_crt *chain,
|
|||
/*
|
||||
* Add new certificate on the end of the chain if needed.
|
||||
*/
|
||||
if( crt->version != 0 && crt->next == NULL )
|
||||
if( crt->raw.p != NULL && crt->next == NULL )
|
||||
{
|
||||
crt->next = mbedtls_calloc( 1, sizeof( mbedtls_x509_crt ) );
|
||||
|
||||
|
|
Loading…
Reference in a new issue