Skip to content

Commit 4a7cbbf

Browse files
committed
fix(mbedtls): Fix dynamic buffer mbedtls handshake steps process return 0 when handshake fail
1 parent b921e0c commit 4a7cbbf

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

components/mbedtls/port/dynamic/esp_mbedtls_dynamic_impl.h

-3
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@
3333
\
3434
if ((_ret = _fn) != 0) { \
3535
ESP_LOGV(TAG, "\"%s\" result is -0x%x", # _fn, -_ret); \
36-
if (_ret == MBEDTLS_ERR_SSL_CONN_EOF) {\
37-
return 0; \
38-
} \
3936
TRACE_CHECK(_fn, "fail"); \
4037
return _ret; \
4138
} \

components/mbedtls/port/dynamic/esp_ssl_tls.c

+10-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,16 @@ int __wrap_mbedtls_ssl_read(mbedtls_ssl_context *ssl, unsigned char *buf, size_t
8585
{
8686
int ret;
8787

88-
CHECK_OK(esp_mbedtls_add_rx_buffer(ssl));
88+
ESP_LOGD(TAG, "add mbedtls RX buffer");
89+
ret = esp_mbedtls_add_rx_buffer(ssl);
90+
if (ret == MBEDTLS_ERR_SSL_CONN_EOF) {
91+
ESP_LOGD(TAG, "fail, the connection indicated an EOF");
92+
return 0;
93+
} else if (ret < 0) {
94+
ESP_LOGD(TAG, "fail, error=-0x%x", -ret);
95+
return ret;
96+
}
97+
ESP_LOGD(TAG, "end");
8998

9099
ret = __real_mbedtls_ssl_read(ssl, buf, len);
91100

0 commit comments

Comments
 (0)