wolfssl icon indicating copy to clipboard operation
wolfssl copied to clipboard

Add missing BIO_should_read and BIO_should_write functions

Open darktohka opened this issue 3 years ago • 5 comments

Description

Currently, BIO_should_retry exists as a component of the OpenSSL compatibility layer. However, there is no way to check the should_read/should_write flag of a BIO object - the BIO_should_read and BIO_should_write functions from OpenSSL are not implemented.

I've implemented the two missing functions as wolfSSL_BIO_should_read and wolfSSL_BIO_should_write by letting wolfSSL check the flags of the BIO, then created the compatibility definitions for BIO_should_read and BIO_should_write in the OpenSSL compatibility header.

Testing

I've created two unit tests, test_wolfSSL_BIO_should_read and test_wolfSSL_BIO_should_write. They each test the respective function before creating the connection and when a read or write is expected to happen.

I've ran the unit_test program after creating these unit tests, and all unit tests completed successfully.

Checklist

  • [X] added tests
  • [ ] updated/added doxygen
  • [ ] updated appropriate READMEs
  • [ ] Updated manual and documentation

darktohka avatar Jul 27 '22 14:07 darktohka

Can one of the wolfSSL admins verify this patch?

wolfSSL-Bot avatar Jul 27 '22 14:07 wolfSSL-Bot

Approved as contributor.

embhorn avatar Aug 01 '22 13:08 embhorn

Okay to test

embhorn avatar Aug 01 '22 13:08 embhorn

retest this please

dgarske avatar Aug 02 '22 21:08 dgarske

@darktohka :

Testing: ./configure --enable-all
Running: make check
make[2]: warning: -j5 forced in submake: resetting jobserver mode.
tests/api.c:40013:10: error: unused variable 'ret' [-Werror,-Wunused-variable]
    int  ret;
         ^
tests/api.c:40051:14: error: variable 'bio' is uninitialized when used here [-Werror,-Wuninitialized]
    BIO_read(bio, reply, sizeof(reply));
             ^~~
tests/api.c:40014:13: note: initialize the variable 'bio' to silence this warning
    BIO* bio;
            ^
             = NULL
tests/api.c:40048:26: error: variable 'ssl' is uninitialized when used here [-Werror,-Wuninitialized]
    wolfSSL_SSLSetIORecv(ssl, EmbedReceive);
                         ^~~
tests/api.c:40009:21: note: initialize the variable 'ssl' to silence this warning
    WOLFSSL*     ssl;
                    ^
                     = NULL
tests/api.c:40084:10: error: unused variable 'ret' [-Werror,-Wunused-variable]
    int  ret;
         ^
tests/api.c:40121:14: error: variable 'bio' is uninitialized when used here [-Werror,-Wuninitialized]
    BIO_read(bio, reply, sizeof(reply));
             ^~~
tests/api.c:40085:13: note: initialize the variable 'bio' to silence this warning
    BIO* bio;
            ^
             = NULL
tests/api.c:40118:26: error: variable 'ssl' is uninitialized when used here [-Werror,-Wuninitialized]
    wolfSSL_SSLSetIORecv(ssl, EmbedReceive);
                         ^~~
tests/api.c:40080:21: note: initialize the variable 'ssl' to silence this warning
    WOLFSSL*     ssl;
                    ^
                     = NULL
6 errors generated.

dgarske avatar Aug 03 '22 14:08 dgarske

Can one of the admins verify this patch?

wolfSSL-Bot avatar Feb 09 '23 20:02 wolfSSL-Bot