Skip to content

Commit

Permalink
Fix ssl error success (#687)
Browse files Browse the repository at this point in the history
* tls.c: remove unused switch

Subj

Signed-off-by: rkhapov <r.khapov@ya.ru>

* machinarium/tls.c: fix handling ssl error 0

That means EOF

Signed-off-by: rkhapov <r.khapov@ya.ru>

---------

Signed-off-by: rkhapov <r.khapov@ya.ru>
Co-authored-by: rkhapov <r.khapov@ya.ru>
  • Loading branch information
rkhapov and rkhapov authored Sep 12, 2024
1 parent 39663a3 commit d7a32b7
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions third_party/machinarium/sources/tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,22 +126,22 @@ static inline char *mm_tls_strerror(int error)

static inline void mm_tls_error(mm_io_t *io, int ssl_rc, char *fmt, ...)
{
/* get error description */
/*
* Use OpenSSL error description or strerror if needed
* See https://docs.openssl.org/master/man3/SSL_get_error/#return-values
*/

unsigned int error;
error = SSL_get_error(io->tls_ssl, ssl_rc);
switch (error) {
case SSL_ERROR_NONE:
case SSL_ERROR_ZERO_RETURN:
/* basically this means connection reset */
break;
}
unsigned int error_peek;
char *error_str;
error_str = "unknown error";
error_peek = ERR_get_error();
if (error_peek != 0) {
if (error_peek > 0) {
error_str = ERR_error_string(error_peek, NULL);
} else if (ssl_rc <= 0) {
} else if (ssl_rc == 0) {
error_str = "unexpected EOF (connection reset)";
} else if (ssl_rc < 0) {
error_str = strerror(mm_errno_get());
}

Expand Down

0 comments on commit d7a32b7

Please sign in to comment.