set bio flag obviously

fix nightly Qt test
This commit is contained in:
Hideki Miyazaki
2022-03-04 19:43:32 +09:00
parent 9be0633ce3
commit a572c19268
2 changed files with 45 additions and 1 deletions

View File

@@ -17568,7 +17568,12 @@ int wolfSSL_set_compression(WOLFSSL* ssl)
wolfSSL_BIO_free(ssl->biord); wolfSSL_BIO_free(ssl->biord);
ssl->biord = NULL; ssl->biord = NULL;
} }
/* set flag obviously */
if (rd && !(rd->flags & WOLFSSL_BIO_FLAG_READ))
rd->flags |= WOLFSSL_BIO_FLAG_READ;
if (wr && !(wr->flags & WOLFSSL_BIO_FLAG_WRITE))
wr->flags |= WOLFSSL_BIO_FLAG_WRITE;
ssl->biord = rd; ssl->biord = rd;
ssl->biowr = wr; ssl->biowr = wr;

View File

@@ -38775,6 +38775,44 @@ static void test_wolfSSL_BIO_connect(void)
#endif #endif
} }
static void test_wolfSSL_BIO_Qt_usecase()
{
#if !defined(NO_BIO) && defined(OPENSSL_EXTRA)
printf(testingFmt, "test_wolfSSL_BIO_Qt_usecase()");
SSL_CTX* ctx;
SSL *ssl;
BIO *readBio;
BIO *writeBio;
int ret, err;
AssertNotNull(ctx = SSL_CTX_new(SSLv23_method()));
AssertNotNull(ssl = SSL_new(ctx));
AssertNotNull(readBio = BIO_new(BIO_s_mem()));
AssertNotNull(writeBio = BIO_new(BIO_s_mem()));
/* Qt reads data from write-bio,
* then writes the read data into plain packet.
* Qt reads data from plain packet,
* then writes the read data into read-bio.
*/
SSL_set_bio(ssl, readBio, writeBio);
AssertIntEQ(ret = SSL_connect(ssl), -1);
err = SSL_get_error(ssl, ret);
/* in this use case, should return WANT READ
* so that Qt will read the data from plain packet for next state.
*/
AssertIntEQ(err, SSL_ERROR_WANT_READ);
SSL_free(ssl);
SSL_CTX_free(ctx);
printf(resultFmt, passed);
#endif
}
#if defined(OPENSSL_ALL) && defined(HAVE_IO_TESTS_DEPENDENCIES) && defined(HAVE_HTTP_CLIENT) #if defined(OPENSSL_ALL) && defined(HAVE_IO_TESTS_DEPENDENCIES) && defined(HAVE_HTTP_CLIENT)
static THREAD_RETURN WOLFSSL_THREAD test_wolfSSL_BIO_accept_client(void* args) static THREAD_RETURN WOLFSSL_THREAD test_wolfSSL_BIO_accept_client(void* args)
{ {
@@ -52684,6 +52722,7 @@ void ApiTest(void)
test_wolfSSL_BIO_printf(); test_wolfSSL_BIO_printf();
test_wolfSSL_BIO_f_md(); test_wolfSSL_BIO_f_md();
test_wolfSSL_BIO_up_ref(); test_wolfSSL_BIO_up_ref();
test_wolfSSL_BIO_Qt_usecase();
#endif #endif
test_wolfSSL_cert_cb(); test_wolfSSL_cert_cb();
test_wolfSSL_SESSION(); test_wolfSSL_SESSION();