Package: wmbiff
Version: 0.4.31-1
Severity: important
Tags: upstream patch

If gnutls_read() or read() report EAGAIN, tlscomm_expect() fails:

wmbiff/nyet  comm: wrote a000 CAPABILITY
wmbiff/nyet  comm: imap.***.***:993: expecting: * CAPABILITY
wmbiff/nyet  comm: imap.***.***:993: gnutls error reading: Resource temporarily 
unavailable, try again.
wmbiff/nyet  imap4: unable to query capability stringwmbiff/nyet  comm: wrote 
a002 LOGOUT
wmbiff/nyet  comm: imap.***.***:993: closing.

-- System Information:
Debian Release: buster/sid
  APT prefers unstable-debug
  APT policy: (500, 'unstable-debug'), (500, 'testing-debug'), (500, 
'unstable'), (500, 'oldstable'), (1, 'experimental-debug')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.19.0-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages wmbiff depends on:
ii  libc6        2.28-2
ii  libgcrypt20  1.8.4-4
ii  libgnutls30  3.6.5-2
ii  libx11-6     2:1.6.7-1
ii  libxext6     2:1.3.3-1+b2
ii  libxpm4      1:3.5.12-1

wmbiff recommends no packages.

Versions of packages wmbiff suggests:
ii  ruby         1:2.5.1
pn  ssh-askpass  <none>

-- no debconf information
diff --git a/wmbiff/Imap4Client.c b/wmbiff/Imap4Client.c
index ba12a66..ea24dd9 100644
--- a/wmbiff/Imap4Client.c
+++ b/wmbiff/Imap4Client.c
@@ -258,7 +258,7 @@ FILE *imap_open(Pop3 pc)
           encrypted session. */
        tlscomm_printf(scs, "a000 CAPABILITY\r\n");
        if (tlscomm_expect(scs, "* CAPABILITY", capabilities, BUF_SIZE) == 0) {
-               IMAP_DM(pc, DEBUG_ERROR, "unable to query capability string");
+               IMAP_DM(pc, DEBUG_ERROR, "unable to query capability string\n");
                goto communication_failure;
        }
 
diff --git a/wmbiff/tlsComm.c b/wmbiff/tlsComm.c
index 85426a0..f37f3f5 100644
--- a/wmbiff/tlsComm.c
+++ b/wmbiff/tlsComm.c
@@ -229,10 +229,12 @@ tlscomm_expect(struct connection_state *scs,
 #ifdef USE_GNUTLS
                        if (scs->tls_state) {
                                /* BUF_SIZE - 1 leaves room for trailing \0 */
-                               thisreadbytes =
-                                       gnutls_read(scs->tls_state,
-                                                               
&scs->unprocessed[buffered_bytes],
-                                                               BUF_SIZE - 1 - 
buffered_bytes);
+                               do {
+                                       thisreadbytes =
+                                               gnutls_read(scs->tls_state,
+                                                                       
&scs->unprocessed[buffered_bytes],
+                                                                       
BUF_SIZE - 1 - buffered_bytes);
+                               } while (thisreadbytes == GNUTLS_E_AGAIN);
                                if (thisreadbytes < 0) {
                                        handle_gnutls_read_error(thisreadbytes, 
scs);
                                        return 0;
@@ -240,9 +242,11 @@ tlscomm_expect(struct connection_state *scs,
                        } else
 #endif
                        {
-                               thisreadbytes =
-                                       read(scs->sd, 
&scs->unprocessed[buffered_bytes],
-                                                BUF_SIZE - 1 - buffered_bytes);
+                               do {
+                                       thisreadbytes =
+                                               read(scs->sd, 
&scs->unprocessed[buffered_bytes],
+                                                        BUF_SIZE - 1 - 
buffered_bytes);
+                               } while (thisreadbytes == EAGAIN);
                                if (thisreadbytes < 0) {
                                        TDM(DEBUG_ERROR, "%s: error reading: 
%s\n",
                                                scs->name, strerror(errno));

Reply via email to