Skip to content

Missing check or conservative conversion of error codes at wolfSSL_write/read #3213

@ErrReporter

Description

@ErrReporter

https://github.com/wolfSSL/wolfssl/blob/4f30e370944498d024f1735f0ffd5c9cdfbaa858/src/ssl.c#L1895

In function wolfSSL_read_internal, the ret variable can be overwritten by return value of NotifyWriteSide. So this error is ignored.

    ret = ReceiveData(ssl, (byte*)data, sz, peek);

#ifdef HAVE_WRITE_DUP
    if (ssl->dupWrite) {
        if (ssl->error != 0 && ssl->error != WANT_READ
        #ifdef WOLFSSL_ASYNC_CRYPT
            && ssl->error != WC_PENDING_E
        #endif
        ) {
            int notifyErr;

            WOLFSSL_MSG("Notifying write side of fatal read error");
            notifyErr  = NotifyWriteSide(ssl, ssl->error);
            if (notifyErr < 0) {
                ret = ssl->error = notifyErr;
            }
        }
    }
#endif

Even the error is correctly received, in the end, the original error code does not held at:

if (ret < 0)
        return WOLFSSL_FATAL_ERROR;

It means all errors become a fatal error, which makes it hard to locate where is the problem. Shall we just keep error codes from ReceiveData or other APIs since they are defined errors from the manual?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions