mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-03-31 10:20:45 +00:00
fix various issue on pending send alert
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
This commit is contained in:
parent
bbd5a3fded
commit
3bf1f97a0e
@ -5640,9 +5640,10 @@ void mbedtls_ssl_read_version( int *major, int *minor, int transport,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Send pending fatal alerts or warnings.
|
* Send pending fatal alert.
|
||||||
* 0, No alert message.
|
* 0, No alert message.
|
||||||
* !0, error from send_alert_message or handshake_step return
|
* !0, if mbedtls_ssl_send_alert_message() returned in error, the error code it
|
||||||
|
* returned, ssl->alert_reason otherwise.
|
||||||
*/
|
*/
|
||||||
int mbedtls_ssl_handle_pending_alert( mbedtls_ssl_context *ssl )
|
int mbedtls_ssl_handle_pending_alert( mbedtls_ssl_context *ssl )
|
||||||
{
|
{
|
||||||
@ -5656,8 +5657,8 @@ int mbedtls_ssl_handle_pending_alert( mbedtls_ssl_context *ssl )
|
|||||||
MBEDTLS_SSL_ALERT_LEVEL_FATAL,
|
MBEDTLS_SSL_ALERT_LEVEL_FATAL,
|
||||||
ssl->alert_type );
|
ssl->alert_type );
|
||||||
|
|
||||||
/* Success or send message fail, clear send_alert flag
|
/* If mbedtls_ssl_send_alert_message() returned with MBEDTLS_ERR_SSL_WANT_WRITE,
|
||||||
* except WANT_WRITE. WANT_WRITE means need re-send message.
|
* do not clear the alert to be able to send it later.
|
||||||
*/
|
*/
|
||||||
if( ret != MBEDTLS_ERR_SSL_WANT_WRITE )
|
if( ret != MBEDTLS_ERR_SSL_WANT_WRITE )
|
||||||
{
|
{
|
||||||
@ -5665,12 +5666,8 @@ int mbedtls_ssl_handle_pending_alert( mbedtls_ssl_context *ssl )
|
|||||||
}
|
}
|
||||||
|
|
||||||
if( ret != 0 )
|
if( ret != 0 )
|
||||||
{
|
|
||||||
/* some errors on send alert message */
|
|
||||||
return( ret );
|
return( ret );
|
||||||
}
|
|
||||||
|
|
||||||
/* Assume alert_reason == handshake_step return */
|
|
||||||
return( ssl->alert_reason );
|
return( ssl->alert_reason );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5208,13 +5208,9 @@ int mbedtls_ssl_handshake_step( mbedtls_ssl_context *ssl )
|
|||||||
/* handshake_step return error. And it is same
|
/* handshake_step return error. And it is same
|
||||||
* with alert_reason.
|
* with alert_reason.
|
||||||
*/
|
*/
|
||||||
int alert_ret;
|
if( ssl->send_alert )
|
||||||
alert_ret = mbedtls_ssl_handle_pending_alert( ssl );
|
|
||||||
if( alert_ret != 0 )
|
|
||||||
{
|
{
|
||||||
/* If success send, ret == alert_ret.
|
ret = mbedtls_ssl_handle_pending_alert( ssl );
|
||||||
*/
|
|
||||||
ret = alert_ret;
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user