send debug msg if contains '\n'
Signed-off-by: valord577 <valord577@gmail.com>
This commit is contained in:
parent
9ecf5f96df
commit
24da0cd0f9
1 changed files with 19 additions and 8 deletions
|
@ -68,6 +68,7 @@ void mbedtls_debug_print_msg(const mbedtls_ssl_context *ssl, int level,
|
|||
va_list argp;
|
||||
char str[DEBUG_BUF_SIZE];
|
||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
int newline = -1;
|
||||
|
||||
if (NULL == ssl ||
|
||||
NULL == ssl->conf ||
|
||||
|
@ -80,16 +81,26 @@ 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';
|
||||
}
|
||||
else
|
||||
{
|
||||
str[DEBUG_BUF_SIZE - 2] = '\n';
|
||||
if (DEBUG_BUF_SIZE >= 2) {
|
||||
if (ret < 0) {
|
||||
newline = 0;
|
||||
} else {
|
||||
newline = ret;
|
||||
if (ret >= DEBUG_BUF_SIZE - 1) {
|
||||
newline = DEBUG_BUF_SIZE - 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
debug_send_line(ssl, level, file, line, str);
|
||||
/*
|
||||
* Send if str contains '\n'.
|
||||
*/
|
||||
if (newline >= 0) {
|
||||
str[newline] = '\n';
|
||||
str[newline + 1] = '\0';
|
||||
|
||||
debug_send_line(ssl, level, file, line, str);
|
||||
}
|
||||
}
|
||||
|
||||
void mbedtls_debug_print_ret(const mbedtls_ssl_context *ssl, int level,
|
||||
|
|
Loading…
Reference in a new issue