From: Aaron Jones Date: Fri, 9 Sep 2016 01:46:20 +0000 (+0000) Subject: MbedTLS: Treat 0 bytes read/written to socket properly X-Git-Url: https://jfr.im/git/solanum.git/commitdiff_plain/73c486c7a5c153e4dad0a496b5f072ee288d4fc4 MbedTLS: Treat 0 bytes read/written to socket properly At the moment, if a link quits in just the right (wrong [1]) way, the quit reason will resemble: <-- foo (~bar@baz) has quit (Read error: (-0x0) ) This should resolve that. [1] Peers should send a close_notify alert before abruptly shutting down their socket. This will result in a sane quit message: <-- foo (~bar@baz) has quit (Read error: (-0x7880) SSL - The peer notified us that the connection is going to be closed) [ci skip] --- diff --git a/librb/src/mbedtls.c b/librb/src/mbedtls.c index 097fb811..006ab20d 100644 --- a/librb/src/mbedtls.c +++ b/librb/src/mbedtls.c @@ -680,7 +680,7 @@ rb_ssl_read(rb_fde_t *const F, void *const buf, size_t count) ssize_t ret = (ssize_t) mbedtls_ssl_read(SSL_P(F), buf, count); - if(ret > 0) + if(ret >= 0) return ret; switch(ret) @@ -706,7 +706,7 @@ rb_ssl_write(rb_fde_t *const F, const void *const buf, size_t count) ssize_t ret = (ssize_t) mbedtls_ssl_write(SSL_P(F), buf, count); - if(ret > 0) + if(ret >= 0) return ret; switch(ret)