diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index 206ac07c938..80dd1d54a8b 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -2866,7 +2866,7 @@ static wc_test_ret_t _SaveDerAndPem(const byte* der, int derSz, WOLFSSL_TEST_SUBROUTINE wc_test_ret_t error_test(void) { const char* errStr; - char out[WOLFSSL_MAX_ERROR_SZ]; + char out[WOLFSSL_MAX_ERROR_SZ]; /* test fails if too small, < 64 */ const char* unknownStr = wc_GetErrorString(0); #ifdef NO_ERROR_STRINGS diff --git a/wolfssl/wolfcrypt/types.h b/wolfssl/wolfcrypt/types.h index df89dd4e2b2..00356e4db07 100644 --- a/wolfssl/wolfcrypt/types.h +++ b/wolfssl/wolfcrypt/types.h @@ -1199,7 +1199,13 @@ enum { }; /* max error buffer string size */ -#ifndef WOLFSSL_MAX_ERROR_SZ +#ifdef WOLFSSL_MAX_ERROR_SZ + #if WOLFSSL_MAX_ERROR_SZ < 64 + /* If too small, the error_test() will fail. + * See fixed length strings returned in wc_GetErrorString() */ + #error WOLFSSL_MAX_ERROR_SZ must be at least length of longest message + #endif +#else #define WOLFSSL_MAX_ERROR_SZ 80 #endif