Minor fix for the expected failure case use of ssl after free. Renamed skipExit to exitWithRet.

This commit is contained in:
David Garske
2018-05-03 10:02:59 -07:00
parent 89a4c98670
commit 325402cf5a
3 changed files with 20 additions and 18 deletions

View File

@@ -796,7 +796,7 @@ static void Usage(void)
#ifdef HAVE_WNR #ifdef HAVE_WNR
printf("-q <file> Whitewood config file, default %s\n", wnrConfig); printf("-q <file> Whitewood config file, default %s\n", wnrConfig);
#endif #endif
printf("-H <arg> Internal tests [defCipherList, skipExit]\n"); printf("-H <arg> Internal tests [defCipherList, exitWithRet]\n");
#ifdef WOLFSSL_TLS13 #ifdef WOLFSSL_TLS13
printf("-J Use HelloRetryRequest to choose group for KE\n"); printf("-J Use HelloRetryRequest to choose group for KE\n");
printf("-K Key Exchange for PSK not using (EC)DHE\n"); printf("-K Key Exchange for PSK not using (EC)DHE\n");
@@ -936,7 +936,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
char* ocspUrl = NULL; char* ocspUrl = NULL;
#endif #endif
int useX25519 = 0; int useX25519 = 0;
int skipExit = 0; int exitWithRet = 0;
#ifdef HAVE_WNR #ifdef HAVE_WNR
const char* wnrConfigFile = wnrConfig; const char* wnrConfigFile = wnrConfig;
@@ -1112,9 +1112,9 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
printf("Using default cipher list for testing\n"); printf("Using default cipher list for testing\n");
useDefCipherList = 1; useDefCipherList = 1;
} }
else if (XSTRNCMP(myoptarg, "skipExit", 7) == 0) { else if (XSTRNCMP(myoptarg, "exitWithRet", 7) == 0) {
printf("Skip exit() for testing\n"); printf("Skip exit() for testing\n");
skipExit = 1; exitWithRet = 1;
} }
else { else {
Usage(); Usage();
@@ -2100,18 +2100,20 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
ret = NonBlockingSSL_Connect(ssl); /* will keep retrying on timeout */ ret = NonBlockingSSL_Connect(ssl); /* will keep retrying on timeout */
#endif #endif
if (ret != WOLFSSL_SUCCESS) { if (ret != WOLFSSL_SUCCESS) {
err = wolfSSL_get_error(ssl, 0);
printf("wolfSSL_connect error %d, %s\n", err, printf("wolfSSL_connect error %d, %s\n", err,
wolfSSL_ERR_error_string(err, buffer)); wolfSSL_ERR_error_string(err, buffer));
/* cleanup */
wolfSSL_free(ssl); wolfSSL_free(ssl);
wolfSSL_CTX_free(ctx); wolfSSL_CTX_free(ctx);
CloseSocket(sockfd); CloseSocket(sockfd);
if (!skipExit) if (!exitWithRet)
err_sys("wolfSSL_connect failed"); err_sys("wolfSSL_connect failed");
/* see note at top of README */ /* see note at top of README */
/* if you're getting an error here */ /* if you're getting an error here */
err = wolfSSL_get_error(ssl, 0);
((func_args*)args)->return_code = err; ((func_args*)args)->return_code = err;
return 0; return 0;
} }

View File

@@ -413,7 +413,7 @@ static void Usage(void)
#endif #endif
printf("-g Return basic HTML web page\n"); printf("-g Return basic HTML web page\n");
printf("-C <num> The number of connections to accept, default: 1\n"); printf("-C <num> The number of connections to accept, default: 1\n");
printf("-H <arg> Internal tests [defCipherList, skipExit]\n"); printf("-H <arg> Internal tests [defCipherList, exitWithRet]\n");
#ifdef WOLFSSL_TLS13 #ifdef WOLFSSL_TLS13
printf("-U Update keys and IVs before sending\n"); printf("-U Update keys and IVs before sending\n");
printf("-K Key Exchange for PSK not using (EC)DHE\n"); printf("-K Key Exchange for PSK not using (EC)DHE\n");
@@ -563,7 +563,7 @@ THREAD_RETURN CYASSL_THREAD server_test(void* args)
int noTicket = 0; int noTicket = 0;
#endif #endif
int useX25519 = 0; int useX25519 = 0;
int skipExit = 0; int exitWithRet = 0;
((func_args*)args)->return_code = -1; /* error state */ ((func_args*)args)->return_code = -1; /* error state */
@@ -693,9 +693,9 @@ THREAD_RETURN CYASSL_THREAD server_test(void* args)
printf("Using default cipher list for testing\n"); printf("Using default cipher list for testing\n");
useDefCipherList = 1; useDefCipherList = 1;
} }
else if (XSTRNCMP(myoptarg, "skipExit", 7) == 0) { else if (XSTRNCMP(myoptarg, "exitWithRet", 7) == 0) {
printf("Skip exit() for testing\n"); printf("Skip exit() for testing\n");
skipExit = 1; exitWithRet = 1;
} }
else { else {
Usage(); Usage();
@@ -1480,15 +1480,15 @@ THREAD_RETURN CYASSL_THREAD server_test(void* args)
err = SSL_get_error(ssl, 0); err = SSL_get_error(ssl, 0);
printf("SSL_accept error %d, %s\n", err, printf("SSL_accept error %d, %s\n", err,
ERR_error_string(err, buffer)); ERR_error_string(err, buffer));
/* cleanup */
if (!skipExit)
err_sys_ex(runWithErrors, "SSL_accept failed");
/* cleanup and return */
SSL_free(ssl); SSL_free(ssl);
SSL_CTX_free(ctx); SSL_CTX_free(ctx);
CloseSocket(clientfd); CloseSocket(clientfd);
CloseSocket(sockfd); CloseSocket(sockfd);
if (!exitWithRet)
err_sys_ex(runWithErrors, "SSL_accept failed");
((func_args*)args)->return_code = err; ((func_args*)args)->return_code = err;
return 0; return 0;
} }

View File

@@ -56,7 +56,7 @@ static char flagSep[] = " ";
static char svrPort[] = "0"; static char svrPort[] = "0";
#endif #endif
static char forceDefCipherListFlag[] = "-HdefCipherList"; static char forceDefCipherListFlag[] = "-HdefCipherList";
static char skipExitFlag[] = "-HskipExit"; static char exitWithRetFlag[] = "-HexitWithRet";
#ifdef WOLFSSL_ASYNC_CRYPT #ifdef WOLFSSL_ASYNC_CRYPT
static int devId = INVALID_DEVID; static int devId = INVALID_DEVID;
@@ -266,7 +266,7 @@ static int execute_test_case(int svr_argc, char** svr_argv,
svr_argv[svrArgs.argc++] = (char*)"-P"; svr_argv[svrArgs.argc++] = (char*)"-P";
#endif #endif
if (testShouldFail) { if (testShouldFail) {
svr_argv[svrArgs.argc++] = skipExitFlag; svr_argv[svrArgs.argc++] = exitWithRetFlag;
} }
/* update server flags list */ /* update server flags list */
@@ -332,7 +332,7 @@ static int execute_test_case(int svr_argc, char** svr_argv,
cli_argv[cliArgs.argc++] = (char*)"-P"; cli_argv[cliArgs.argc++] = (char*)"-P";
#endif #endif
if (testShouldFail) { if (testShouldFail) {
cli_argv[cliArgs.argc++] = skipExitFlag; cli_argv[cliArgs.argc++] = exitWithRetFlag;
} }
commandLine[0] = '\0'; commandLine[0] = '\0';