use external CYASSL_MAX_ERROR_SZ for buffer size

This commit is contained in:
toddouska
2013-08-06 11:48:00 -07:00
parent 427a421ec5
commit 5c5cee0789
10 changed files with 18 additions and 14 deletions

View File

@@ -35,7 +35,7 @@
void CTaoCryptErrorString(int error, char* buffer)
{
const int max = MAX_ERROR_SZ; /* shorthand */
const int max = CYASSL_MAX_ERROR_SZ; /* shorthand */
#ifdef NO_ERROR_STRINGS

View File

@@ -33,7 +33,6 @@
/* error codes */
enum {
MAX_ERROR_SZ = 80, /* max size of error string */
MAX_CODE_E = -100, /* errors -101 - -199 */
OPEN_RAN_E = -101, /* opening random device error */
READ_RAN_E = -102, /* reading random device error */

View File

@@ -247,6 +247,11 @@ enum {
DYNAMIC_TYPE_TLSX = 43
};
/* max error buffer string size */
enum {
CYASSL_MAX_ERROR_SZ = 80
};
/* stack protection */
enum {
MIN_STACK_BUFFER = 8

View File

@@ -850,7 +850,7 @@ static INLINE unsigned int my_psk_server_cb(CYASSL* ssl, const char* identity,
static INLINE int myVerify(int preverify, CYASSL_X509_STORE_CTX* store)
{
char buffer[80];
char buffer[CYASSL_MAX_ERROR_SZ];
#ifdef OPENSSL_EXTRA
CYASSL_X509* peer;

View File

@@ -608,7 +608,7 @@ THREAD_RETURN CYASSL_THREAD client_test(void* args)
else if (CyaSSL_connect(ssl) != SSL_SUCCESS) {
/* see note at top of README */
int err = CyaSSL_get_error(ssl, 0);
char buffer[80];
char buffer[CYASSL_MAX_ERROR_SZ];
printf("err = %d, %s\n", err,
CyaSSL_ERR_error_string(err, buffer));
err_sys("SSL_connect failed");

View File

@@ -475,7 +475,7 @@ THREAD_RETURN CYASSL_THREAD server_test(void* args)
NonBlockingSSL_Accept(ssl);
} else if (SSL_accept(ssl) != SSL_SUCCESS) {
int err = SSL_get_error(ssl, 0);
char buffer[80];
char buffer[CYASSL_MAX_ERROR_SZ];
printf("error = %d, %s\n", err, ERR_error_string(err, buffer));
err_sys("SSL_accept failed");
}

View File

@@ -5581,7 +5581,7 @@ int SendAlert(CYASSL* ssl, int severity, int type)
void SetErrorString(int error, char* str)
{
const int max = MAX_ERROR_SZ; /* shorthand */
const int max = CYASSL_MAX_ERROR_SZ; /* shorthand */
#ifdef NO_ERROR_STRINGS

View File

@@ -762,10 +762,10 @@ char* CyaSSL_ERR_error_string(unsigned long errNumber, char* data)
void CyaSSL_ERR_error_string_n(unsigned long e, char* buf, unsigned long len)
{
CYASSL_ENTER("CyaSSL_ERR_error_string_n");
if (len >= MAX_ERROR_SZ)
if (len >= CYASSL_MAX_ERROR_SZ)
CyaSSL_ERR_error_string(e, buf);
else {
char tmp[MAX_ERROR_SZ];
char tmp[CYASSL_MAX_ERROR_SZ];
CYASSL_MSG("Error buffer too short, truncating");
if (len) {
@@ -873,7 +873,7 @@ int CyaSSL_CertManagerUnloadCAs(CYASSL_CERT_MANAGER* cm)
void CyaSSL_ERR_print_errors_fp(FILE* fp, int err)
{
char data[MAX_ERROR_SZ + 1];
char data[CYASSL_MAX_ERROR_SZ + 1];
CYASSL_ENTER("CyaSSL_ERR_print_errors_fp");
SetErrorString(err, data);

View File

@@ -176,7 +176,7 @@ int CyaSSL_swig_connect(CYASSL* ssl, const char* server, int port)
char* CyaSSL_error_string(int err)
{
static char buffer[80];
static char buffer[CYASSL_MAX_ERROR_SZ];
return CyaSSL_ERR_error_string(err, buffer);
}

View File

@@ -887,7 +887,7 @@ THREAD_RETURN CYASSL_THREAD test_server_nofail(void* args)
if (CyaSSL_accept(ssl) != SSL_SUCCESS)
{
int err = CyaSSL_get_error(ssl, 0);
char buffer[80];
char buffer[CYASSL_MAX_ERROR_SZ];
printf("error = %d, %s\n", err, CyaSSL_ERR_error_string(err, buffer));
/*err_sys("SSL_accept failed");*/
goto done;
@@ -963,7 +963,7 @@ void test_client_nofail(void* args)
if (CyaSSL_connect(ssl) != SSL_SUCCESS)
{
int err = CyaSSL_get_error(ssl, 0);
char buffer[80];
char buffer[CYASSL_MAX_ERROR_SZ];
printf("err = %d, %s\n", err, CyaSSL_ERR_error_string(err, buffer));
/*printf("SSL_connect failed");*/
goto done2;
@@ -1031,7 +1031,7 @@ void run_cyassl_client(void* args)
if (CyaSSL_connect(ssl) != SSL_SUCCESS) {
int err = CyaSSL_get_error(ssl, 0);
char buffer[80];
char buffer[CYASSL_MAX_ERROR_SZ];
printf("error = %d, %s\n", err, CyaSSL_ERR_error_string(err, buffer));
} else {
@@ -1108,7 +1108,7 @@ THREAD_RETURN CYASSL_THREAD run_cyassl_server(void* args)
/* AssertIntEQ(SSL_SUCCESS, CyaSSL_accept(ssl)); */
if (CyaSSL_accept(ssl) != SSL_SUCCESS) {
int err = CyaSSL_get_error(ssl, 0);
char buffer[80];
char buffer[CYASSL_MAX_ERROR_SZ];
printf("error = %d, %s\n", err, CyaSSL_ERR_error_string(err, buffer));
} else {