diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2023-08-04 18:09:03 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-08-07 14:39:49 +0200 |
commit | 1f6340bc460023ddcdf7aed952f6f6d75d8d4c0d (patch) | |
tree | 01f51d64008093a272958904537e13ad5a39da6a /thirdparty/mbedtls/library/debug.c | |
parent | faaf27f28492650cf8bfb71328ab21ab934d0dd7 (diff) | |
download | redot-engine-1f6340bc460023ddcdf7aed952f6f6d75d8d4c0d.tar.gz |
mbedtls: Update to upstream version 2.28.4
Diffstat (limited to 'thirdparty/mbedtls/library/debug.c')
-rw-r--r-- | thirdparty/mbedtls/library/debug.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/thirdparty/mbedtls/library/debug.c b/thirdparty/mbedtls/library/debug.c index ab8b3524d4..3e794b5565 100644 --- a/thirdparty/mbedtls/library/debug.c +++ b/thirdparty/mbedtls/library/debug.c @@ -30,6 +30,7 @@ #include <stdio.h> #include <string.h> +/* DEBUG_BUF_SIZE must be at least 2 */ #define DEBUG_BUF_SIZE 512 static int debug_threshold = 0; @@ -69,6 +70,8 @@ void mbedtls_debug_print_msg(const mbedtls_ssl_context *ssl, int level, char str[DEBUG_BUF_SIZE]; int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; + MBEDTLS_STATIC_ASSERT(DEBUG_BUF_SIZE >= 2, "DEBUG_BUF_SIZE too small"); + if (NULL == ssl || NULL == ssl->conf || NULL == ssl->conf->f_dbg || @@ -80,10 +83,15 @@ void mbedtls_debug_print_msg(const mbedtls_ssl_context *ssl, int level, ret = mbedtls_vsnprintf(str, DEBUG_BUF_SIZE, format, argp); va_end(argp); - if (ret >= 0 && ret < DEBUG_BUF_SIZE - 1) { - str[ret] = '\n'; - str[ret + 1] = '\0'; + if (ret < 0) { + ret = 0; + } else { + if (ret >= DEBUG_BUF_SIZE - 1) { + ret = DEBUG_BUF_SIZE - 2; + } } + str[ret] = '\n'; + str[ret + 1] = '\0'; debug_send_line(ssl, level, file, line, str); } |