fixes for defects identified by cppcheck and clang-tidy on --enable-debug builds: null deref in tests/api.c:load_pem_key_file_as_der(), redundant declarations in wolfcrypt/benchmark/benchmark.c, and numerous unchecked XSNPRINTF()s in wolfcrypt/src/logging.c and src/internal.c.

This commit is contained in:
Daniel Pouzzner
2024-08-07 13:13:43 -05:00
parent 5f6067c3e1
commit 763ced668e
4 changed files with 60 additions and 28 deletions

View File

@@ -20653,7 +20653,11 @@ static void LogAlert(int type)
typeStr = AlertTypeToString(type);
if (typeStr != NULL) {
char buff[60];
XSNPRINTF(buff, sizeof(buff), "Alert type: %s", typeStr);
if (XSNPRINTF(buff, sizeof(buff), "Alert type: %s", typeStr)
>= (int)sizeof(buff))
{
buff[sizeof(buff) - 1] = 0;
}
WOLFSSL_MSG(buff);
}
#else