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

View File

@@ -413,7 +413,7 @@ static void Usage(void)
#endif
printf("-g Return basic HTML web page\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
printf("-U Update keys and IVs before sending\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;
#endif
int useX25519 = 0;
int skipExit = 0;
int exitWithRet = 0;
((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");
useDefCipherList = 1;
}
else if (XSTRNCMP(myoptarg, "skipExit", 7) == 0) {
else if (XSTRNCMP(myoptarg, "exitWithRet", 7) == 0) {
printf("Skip exit() for testing\n");
skipExit = 1;
exitWithRet = 1;
}
else {
Usage();
@@ -1480,15 +1480,15 @@ THREAD_RETURN CYASSL_THREAD server_test(void* args)
err = SSL_get_error(ssl, 0);
printf("SSL_accept error %d, %s\n", err,
ERR_error_string(err, buffer));
if (!skipExit)
err_sys_ex(runWithErrors, "SSL_accept failed");
/* cleanup and return */
/* cleanup */
SSL_free(ssl);
SSL_CTX_free(ctx);
CloseSocket(clientfd);
CloseSocket(sockfd);
if (!exitWithRet)
err_sys_ex(runWithErrors, "SSL_accept failed");
((func_args*)args)->return_code = err;
return 0;
}

View File

@@ -56,7 +56,7 @@ static char flagSep[] = " ";
static char svrPort[] = "0";
#endif
static char forceDefCipherListFlag[] = "-HdefCipherList";
static char skipExitFlag[] = "-HskipExit";
static char exitWithRetFlag[] = "-HexitWithRet";
#ifdef WOLFSSL_ASYNC_CRYPT
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";
#endif
if (testShouldFail) {
svr_argv[svrArgs.argc++] = skipExitFlag;
svr_argv[svrArgs.argc++] = exitWithRetFlag;
}
/* 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";
#endif
if (testShouldFail) {
cli_argv[cliArgs.argc++] = skipExitFlag;
cli_argv[cliArgs.argc++] = exitWithRetFlag;
}
commandLine[0] = '\0';