Skip to content

Commit 9648757

Browse files
committed
Detect if WOLFSSL_MAX_ERROR_SZ is too small
1 parent 3f460b4 commit 9648757

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

wolfcrypt/test/test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2866,7 +2866,7 @@ static wc_test_ret_t _SaveDerAndPem(const byte* der, int derSz,
28662866
WOLFSSL_TEST_SUBROUTINE wc_test_ret_t error_test(void)
28672867
{
28682868
const char* errStr;
2869-
char out[WOLFSSL_MAX_ERROR_SZ];
2869+
char out[WOLFSSL_MAX_ERROR_SZ]; /* test fails if too small, < 64 */
28702870
const char* unknownStr = wc_GetErrorString(0);
28712871

28722872
#ifdef NO_ERROR_STRINGS

wolfssl/wolfcrypt/types.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1199,7 +1199,13 @@ enum {
11991199
};
12001200

12011201
/* max error buffer string size */
1202-
#ifndef WOLFSSL_MAX_ERROR_SZ
1202+
#ifdef WOLFSSL_MAX_ERROR_SZ
1203+
#if WOLFSSL_MAX_ERROR_SZ < 64
1204+
/* If too small, the error_test() will fail.
1205+
* See fixed length strings returned in wc_GetErrorString() */
1206+
WOLFSSL_MSG("WOLFSSL_MAX_ERROR_SZ is too small");
1207+
#endif
1208+
#else
12031209
#define WOLFSSL_MAX_ERROR_SZ 80
12041210
#endif
12051211

0 commit comments

Comments
 (0)