Make allocation of reassembly bitmap optional
This commit adds a parameter to ssl_prepare_reassembly_buffer()
allowing to disable the allocation of space for a reassembly bitmap.
This will allow this function to be used for the allocation of buffers
for future handshake messages in case these need no fragmentation.
diff --git a/library/ssl_tls.c b/library/ssl_tls.c
index e0ce692..a9f84d4 100644
--- a/library/ssl_tls.c
+++ b/library/ssl_tls.c
@@ -3473,6 +3473,7 @@
/* msg_len does not include the handshake header */
static int ssl_prepare_reassembly_buffer( mbedtls_ssl_context *ssl, /* debug */
unsigned msg_len,
+ unsigned add_bitmap,
unsigned char **target )
{
size_t alloc_len;
@@ -3490,7 +3491,9 @@
alloc_len = 12; /* Handshake header */
alloc_len += msg_len; /* Content buffer */
- alloc_len += msg_len / 8 + ( msg_len % 8 != 0 ); /* Bitmap */
+
+ if( add_bitmap )
+ alloc_len += msg_len / 8 + ( msg_len % 8 != 0 ); /* Bitmap */
buf = mbedtls_calloc( 1, alloc_len );
if( buf == NULL )
@@ -3528,7 +3531,8 @@
*/
if( ssl->handshake->hs_msg == NULL )
{
- ret = ssl_prepare_reassembly_buffer( msg_len, &ssl->handshake->hs_msg );
+ ret = ssl_prepare_reassembly_buffer( msg_len, 1,
+ &ssl->handshake->hs_msg );
if( ret != 0 )
return( ret );