Describe the behaviour of buffer resizing on an out-of-memory error
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
diff --git a/include/mbedtls/config.h b/include/mbedtls/config.h
index 5534ec4..cf7f403 100644
--- a/include/mbedtls/config.h
+++ b/include/mbedtls/config.h
@@ -1912,7 +1912,11 @@
/**
* \def MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH
*
- * Enable modifying the maximum I/O buffer size.
+ * Enable modifying the maximum I/O buffer size in runtime.
+ *
+ * If the library runs out of memory during the resizing of an I/O buffer,
+ * there is no error returned. The operation continues as usual on an
+ * unchanged buffer without any negative impact on the flow.
*/
//#define MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH
diff --git a/library/ssl_tls.c b/library/ssl_tls.c
index eaa0f6e..eb212d2 100644
--- a/library/ssl_tls.c
+++ b/library/ssl_tls.c
@@ -685,6 +685,8 @@
{
if( resize_buffer( &ssl->in_buf, in_buf_new_len, &ssl->in_buf_len ) != 0 )
{
+ /* No need to return an error here; The buffer will remain as
+ * is with no negative impact on the flow. */
MBEDTLS_SSL_DEBUG_MSG( 1, ( "input buffer resizing failed - out of memory" ) );
}
else
@@ -705,6 +707,8 @@
{
if( resize_buffer( &ssl->out_buf, out_buf_new_len, &ssl->out_buf_len ) != 0 )
{
+ /* No need to return an error here; The buffer will remain as
+ * is with no negative impact on the flow. */
MBEDTLS_SSL_DEBUG_MSG( 1, ( "output buffer resizing failed - out of memory" ) );
}
else