From 1a75461594342da80252ef0ad3aea5d0966ea460 Mon Sep 17 00:00:00 2001 From: Aaron Jones Date: Fri, 16 Sep 2016 22:27:45 +0000 Subject: [PATCH] GNUTLS: Minor fix to rb_ssl_accept_common()/rb_ssl_connect_common() Properly check whether the library was interrupted by the kernel before assuming that a nonzero errno was caused by the kernel. Otherwise, a memory allocation failure in the library for example would incorrectly be interpreted as a syscall error instead of a library error. --- libratbox/src/gnutls.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libratbox/src/gnutls.c b/libratbox/src/gnutls.c index ebe11f31..7b98128d 100644 --- a/libratbox/src/gnutls.c +++ b/libratbox/src/gnutls.c @@ -248,7 +248,7 @@ rb_ssl_accept_common(rb_fde_t *const F, void *const data) F->handshake_count++; ad->callback(F, RB_OK, (struct sockaddr *)&ad->S, ad->addrlen, ad->data); } - else if(err != 0) + else if(ret == GNUTLS_E_INTERRUPTED && err != 0) { errno = err; ad->callback(F, RB_ERROR, NULL, 0, ad->data); @@ -632,7 +632,7 @@ rb_ssl_connect_common(rb_fde_t *const F, void *const data) F->handshake_count++; rb_ssl_connect_realcb(F, RB_OK, sconn); } - else if(err != 0) + else if(ret == GNUTLS_E_INTERRUPTED && err != 0) { errno = err; rb_ssl_connect_realcb(F, RB_ERROR, sconn);