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]
This commit is contained in:
Aaron Jones 2016-09-09 01:41:30 +00:00
parent ee10f6cdcc
commit 2a8ec58c15
No known key found for this signature in database
GPG key ID: EC6F86EE9CD840B5

View file

@ -634,7 +634,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); ssize_t ret = (ssize_t) mbedtls_ssl_read(SSL_P(F), buf, count);
if(ret > 0) if(ret >= 0)
return ret; return ret;
switch(ret) switch(ret)
@ -660,7 +660,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); ssize_t ret = (ssize_t) mbedtls_ssl_write(SSL_P(F), buf, count);
if(ret > 0) if(ret >= 0)
return ret; return ret;
switch(ret) switch(ret)