diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2019-05-22 22:46:55 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2019-05-22 22:52:38 +0300 |
commit | 491151b751c965cbb1158588a09aa28cc19921f6 (patch) | |
tree | cf324ac5030c1b29405cf032b1b00e81a36e2466 | |
parent | 0d271c3709f7f3da81285925b670cdb85b90ccbd (diff) | |
download | mailutils-491151b751c965cbb1158588a09aa28cc19921f6.tar.gz mailutils-491151b751c965cbb1158588a09aa28cc19921f6.tar.bz2 |
Fix a bug in TLS read
This complements afda9ba4. Thanks to Rafael Fontenelle
for helping locate the bug.
* libmu_auth/tlsiostr.c (_tls_io_read): Handle
GNUTLS_E_AGAIN and GNUTLS_E_INTERRUPTED.
* libmailutils/stream/stream.c (mu_stream_seterr): EINTR is a
transient error condition.
* THANKS: Update.
-rw-r--r-- | THANKS | 1 | ||||
-rw-r--r-- | libmailutils/stream/stream.c | 1 | ||||
-rw-r--r-- | libmu_auth/tlsiostr.c | 8 |
3 files changed, 7 insertions, 3 deletions
@@ -23,12 +23,13 @@ Kostas Zorbadelos <kzorba@otenet.gr> Kurt Hackenberg <kh@panix.com> Matthew Whitworth <matthew@okcomputer.org> maks <maksqwe1@ukr.net> Neil R. Ormos <ormos@ormos.org> Olivier Bornet <Olivier.Bornet@smartdata.ch> Pierre-Jean <lists@utroff.org> +Rafael Fontenelle <rafaelff@gnome.org> Robby Villegas <robby.villegas@gmail.com> Ronan KERYELL <Ronan.Keryell@enstb.org> Sam Roberts <sroberts@uniserve.com> Sean 'Shaleh' Perry <shaleh@debian.org> Sergey Poznyakoff <gray@gnu.org.ua> Simon Josefsson <jas@extundo.com> diff --git a/libmailutils/stream/stream.c b/libmailutils/stream/stream.c index ca66d8251..b45f2b1c5 100644 --- a/libmailutils/stream/stream.c +++ b/libmailutils/stream/stream.c @@ -94,12 +94,13 @@ mu_stream_seterr (struct _mu_stream *stream, int code, int perm) { stream->last_err = code; switch (code) { case 0: case EAGAIN: + case EINTR: case ENOSYS: case EINPROGRESS: break; default: if (perm) diff --git a/libmu_auth/tlsiostr.c b/libmu_auth/tlsiostr.c index 5bf4e96e8..bf05ca740 100644 --- a/libmu_auth/tlsiostr.c +++ b/libmu_auth/tlsiostr.c @@ -34,17 +34,19 @@ _tls_io_flush (struct _mu_stream *stream) static int _tls_io_read (struct _mu_stream *stream, char *buf, size_t bufsize, size_t *pnread) { struct _mu_tls_io_stream *sp = (struct _mu_tls_io_stream *) stream; - int rc; + ssize_t rc; if (sp->up->state != state_open) return EINVAL; - rc = gnutls_record_recv (sp->up->session, buf, bufsize); + do + rc = gnutls_record_recv (sp->up->session, buf, bufsize); + while (rc == GNUTLS_E_AGAIN || rc == GNUTLS_E_INTERRUPTED); if (rc >= 0) { *pnread = rc; return 0; } sp->up->tls_err = rc; @@ -53,13 +55,13 @@ _tls_io_read (struct _mu_stream *stream, char *buf, size_t bufsize, static int _tls_io_write (struct _mu_stream *stream, const char *buf, size_t bufsize, size_t *pnwrite) { struct _mu_tls_io_stream *sp = (struct _mu_tls_io_stream *) stream; - int rc; + ssize_t rc; if (sp->up->state != state_open) return EINVAL; /* gnutls_record_send() docs say: If the EINTR is returned by the internal push function (write()) |