forked from wolfSSL/wolfssl
Fixes for various tests that do not properly handle WC_PENDING_E
.
This commit is contained in:
@ -577,8 +577,21 @@ static void ServerRead(WOLFSSL* ssl, char* input, int inputLen)
|
||||
}
|
||||
else if (SSL_get_error(ssl, 0) == 0 &&
|
||||
tcp_select(SSL_get_fd(ssl), 0) == TEST_RECV_READY) {
|
||||
err = wolfSSL_peek(ssl, buffer, 0);
|
||||
if(err < 0) {
|
||||
/* do a peek and check for "pending" */
|
||||
err = 0;
|
||||
do {
|
||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||
if (err == WC_PENDING_E) {
|
||||
ret = wolfSSL_AsyncPoll(ssl, WOLF_POLL_FLAG_CHECK_HW);
|
||||
if (ret < 0) break;
|
||||
}
|
||||
#endif
|
||||
ret = wolfSSL_peek(ssl, buffer, 0);
|
||||
err = SSL_get_error(ssl, ret);
|
||||
} while (err == WC_PENDING_E
|
||||
|| err == WOLFSSL_ERROR_WANT_READ
|
||||
|| err == WOLFSSL_ERROR_WANT_WRITE);
|
||||
if (err < 0) {
|
||||
err_sys_ex(runWithErrors, "wolfSSL_peek failed");
|
||||
}
|
||||
if (wolfSSL_pending(ssl))
|
||||
|
47
tests/api.c
47
tests/api.c
@ -6452,10 +6452,9 @@ static THREAD_RETURN WOLFSSL_THREAD run_wolfssl_server(void* args)
|
||||
if (callbacks->ssl_ready)
|
||||
callbacks->ssl_ready(ssl);
|
||||
|
||||
|
||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||
err = 0; /* Reset error */
|
||||
#endif
|
||||
#endif
|
||||
do {
|
||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||
if (err == WC_PENDING_E) {
|
||||
@ -6464,20 +6463,48 @@ static THREAD_RETURN WOLFSSL_THREAD run_wolfssl_server(void* args)
|
||||
}
|
||||
#endif
|
||||
ret = wolfSSL_accept(ssl);
|
||||
err = wolfSSL_get_error(ssl, 0);
|
||||
err = wolfSSL_get_error(ssl, ret);
|
||||
} while (err == WC_PENDING_E);
|
||||
if (ret != WOLFSSL_SUCCESS) {
|
||||
char buff[WOLFSSL_MAX_ERROR_SZ];
|
||||
printf("error = %d, %s\n", err, wolfSSL_ERR_error_string(err, buff));
|
||||
printf("accept error = %d, %s\n",
|
||||
err, wolfSSL_ERR_error_string(err, buff));
|
||||
/*err_sys("SSL_accept failed");*/
|
||||
}
|
||||
else {
|
||||
if (0 < (idx = wolfSSL_read(ssl, input, sizeof(input)-1))) {
|
||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||
err = 0; /* Reset error */
|
||||
#endif
|
||||
do {
|
||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||
if (err == WC_PENDING_E) {
|
||||
ret = wolfSSL_AsyncPoll(ssl, WOLF_POLL_FLAG_CHECK_HW);
|
||||
if (ret < 0) { break; } else if (ret == 0) { continue; }
|
||||
}
|
||||
#endif
|
||||
idx = wolfSSL_read(ssl, input, sizeof(input)-1);
|
||||
err = wolfSSL_get_error(ssl, idx);
|
||||
} while (err == WC_PENDING_E);
|
||||
if (idx > 0) {
|
||||
input[idx] = 0;
|
||||
printf("Client message: %s\n", input);
|
||||
}
|
||||
|
||||
AssertIntEQ(len, wolfSSL_write(ssl, msg, len));
|
||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||
err = 0; /* Reset error */
|
||||
#endif
|
||||
do {
|
||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||
if (err == WC_PENDING_E) {
|
||||
ret = wolfSSL_AsyncPoll(ssl, WOLF_POLL_FLAG_CHECK_HW);
|
||||
if (ret < 0) { break; } else if (ret == 0) { continue; }
|
||||
}
|
||||
#endif
|
||||
ret = wolfSSL_write(ssl, msg, len);
|
||||
err = wolfSSL_get_error(ssl, ret);
|
||||
} while (err == WC_PENDING_E);
|
||||
AssertIntEQ(len, ret);
|
||||
|
||||
#if defined(WOLFSSL_SESSION_EXPORT) && !defined(HAVE_IO_POOL) && \
|
||||
defined(WOLFSSL_DTLS)
|
||||
if (wolfSSL_dtls(ssl)) {
|
||||
@ -6631,7 +6658,7 @@ static void run_wolfssl_client(void* args)
|
||||
}
|
||||
#endif
|
||||
ret = wolfSSL_connect(ssl);
|
||||
err = wolfSSL_get_error(ssl, 0);
|
||||
err = wolfSSL_get_error(ssl, ret);
|
||||
} while (err == WC_PENDING_E);
|
||||
if (ret != WOLFSSL_SUCCESS) {
|
||||
char buff[WOLFSSL_MAX_ERROR_SZ];
|
||||
@ -6650,7 +6677,7 @@ static void run_wolfssl_client(void* args)
|
||||
}
|
||||
#endif
|
||||
ret = wolfSSL_write(ssl, msg, len);
|
||||
err = wolfSSL_get_error(ssl, 0);
|
||||
err = wolfSSL_get_error(ssl, ret);
|
||||
} while (err == WC_PENDING_E);
|
||||
AssertIntEQ(len, ret);
|
||||
|
||||
@ -6665,7 +6692,7 @@ static void run_wolfssl_client(void* args)
|
||||
}
|
||||
#endif
|
||||
ret = wolfSSL_read(ssl, input, sizeof(input)-1);
|
||||
err = wolfSSL_get_error(ssl, 0);
|
||||
err = wolfSSL_get_error(ssl, ret);
|
||||
} while (err == WC_PENDING_E);
|
||||
if (ret > 0) {
|
||||
input[ret] = '\0'; /* null term */
|
||||
|
@ -122,7 +122,7 @@ This library provides single precision (SP) integer math functions.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* ALLOC_SP_INT: Allocate an 'sp_int' of reqired size. */
|
||||
/* ALLOC_SP_INT: Allocate an 'sp_int' of required size. */
|
||||
#if (defined(WOLFSSL_SMALL_STACK) || defined(SP_ALLOC)) && \
|
||||
!defined(WOLFSSL_SP_NO_MALLOC)
|
||||
/* Dynamically allocate just enough data to support size. */
|
||||
@ -193,7 +193,7 @@ This library provides single precision (SP) integer math functions.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* ALLOC_SP_INT_ARRAY: Allocate an array of 'sp_int's of reqired size. */
|
||||
/* ALLOC_SP_INT_ARRAY: Allocate an array of 'sp_int's of required size. */
|
||||
#if (defined(WOLFSSL_SMALL_STACK) || defined(SP_ALLOC)) && \
|
||||
!defined(WOLFSSL_SP_NO_MALLOC)
|
||||
/* Dynamically allocate just enough data to support multiple sp_ints of the
|
||||
|
Reference in New Issue
Block a user