Allow limiting the total amount of heap allocations for buffering
This commit introduces a compile time constant MBEDTLS_SSL_DTLS_MAX_BUFFERING to mbedtls/config.h which allows the user to control the cumulative size of all heap buffer allocated for the purpose of reassembling and buffering handshake messages. It is put to use by introducing a new field `total_bytes_buffered` to the buffering substructure of `mbedtls_ssl_handshake_params` that keeps track of the total size of heap allocated buffers for the purpose of reassembly and buffering at any time. It is increased whenever a handshake message is buffered or prepared for reassembly, and decreased when a buffered or fully reassembled message is copied into the input buffer and passed to the handshake logic layer. This commit does not yet include future epoch record buffering into account; this will be done in a subsequent commit. Also, it is now conceivable that the reassembly of the next expected handshake message fails because too much buffering space has already been used up for future messages. This case currently leads to an error, but instead, the stack should get rid of buffered messages to be able to buffer the next one. This will need to be implemented in one of the next commits.
This commit is contained in:
parent
2a97b0e7a3
commit
e0b150f96b
4 changed files with 57 additions and 5 deletions
|
@ -311,6 +311,9 @@ struct mbedtls_ssl_handshake_params
|
|||
|
||||
struct
|
||||
{
|
||||
size_t total_bytes_buffered; /*!< Cumulative size of heap allocated
|
||||
* buffers used for message buffering. */
|
||||
|
||||
uint8_t seen_ccs; /*!< Indicates if a CCS message has
|
||||
* been seen in the current flight. */
|
||||
|
||||
|
@ -320,6 +323,7 @@ struct mbedtls_ssl_handshake_params
|
|||
uint8_t is_fragmented : 1;
|
||||
uint8_t is_complete : 1;
|
||||
unsigned char *data;
|
||||
size_t data_len;
|
||||
} hs[MBEDTLS_SSL_MAX_BUFFERED_HS];
|
||||
|
||||
struct
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue