-
Notifications
You must be signed in to change notification settings - Fork 958
Missing check or conservative conversion of error codes at wolfSSL_write/read #3213
Copy link
Copy link
Closed
Labels
Description
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;
}
}
}
#endifEven 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?
Reactions are currently unavailable