Package: sasl2-bin
Version: 2.1.25.dfsg1-6
Severity: important
Tags: patch

Hello,

I met the same bug as 
https://bugs.launchpad.net/ubuntu/+source/cyrus-sasl2/+bug/997217

Here is a patch of 0034-fix_dovecot_authentication.patch 

-- System Information:
Debian Release: 7.0
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: i386 (i686)

Kernel: Linux 3.2.0-4-686-pae (SMP w/4 CPU cores)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=locale: Cannot set 
LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/dash

Versions of packages sasl2-bin depends on:
ii  db-util                5.1.6
ii  debconf [debconf-2.0]  1.5.49
ii  libc6                  2.13-38
ii  libcomerr2             1.42.5-1.1
ii  libdb5.1               5.1.29-5
ii  libgssapi-krb5-2       1.10.1+dfsg-5
ii  libk5crypto3           1.10.1+dfsg-5
ii  libkrb5-3              1.10.1+dfsg-5
ii  libldap-2.4-2          2.4.31-1+nmu2
ii  libpam0g               1.1.3-7.1
ii  libsasl2-2             2.1.25.dfsg1-6
ii  libssl1.0.0            1.0.1e-2
ii  lsb-base               4.1+Debian8

sasl2-bin recommends no packages.

sasl2-bin suggests no packages.

-- debconf information excluded
Index: cyrus-sasl2-2.1.25.dfsg1/saslauthd/auth_rimap.c
===================================================================
--- cyrus-sasl2-2.1.25.dfsg1.orig/saslauthd/auth_rimap.c	2013-05-16 15:36:35.000000000 +0000
+++ cyrus-sasl2-2.1.25.dfsg1/saslauthd/auth_rimap.c	2013-05-16 15:43:24.000000000 +0000
@@ -1,3 +1,4 @@
+
 /* MODULE: auth_rimap */
 
 /* COPYRIGHT
@@ -367,6 +368,39 @@
     alarm(NETWORK_IO_TIMEOUT);
     rc = read(s, rbuf, sizeof(rbuf));
     alarm(0);
+    if ( rc>0 ) {
+        /* check if there is more to read */
+        fd_set         perm;
+        int            fds, ret, loopc;
+        struct timeval timeout;
+
+        FD_ZERO(&perm);
+        FD_SET(s, &perm);
+        fds = s +1;
+
+        timeout.tv_sec  = 1;
+        timeout.tv_usec = 0;
+        loopc = 0;
+        while( select (fds, &perm, NULL, NULL, &timeout ) >0 ) {
+           if ( FD_ISSET(s, &perm) ) {
+              ret = read(s, rbuf+rc, sizeof(rbuf)-rc);
+              if ( ret<0 ) {
+                 rc = ret;
+                 break;
+              } else {
+                 if (ret == 0) {
+                   loopc += 1;
+                 } else {
+                   loopc = 0;
+                 }
+                 if (loopc > sizeof(rbuf)) { // arbitrary chosen value
+                   break;
+                 }
+                 rc += ret;
+              }
+           }
+        }
+    }
     if (rc == -1) {
 	syslog(LOG_WARNING, "auth_rimap: read (banner): %m");
 	(void) close(s);
@@ -456,6 +490,39 @@
     alarm(NETWORK_IO_TIMEOUT);
     rc = read(s, rbuf, sizeof(rbuf));
     alarm(0);
+    if ( rc>0 ) {
+        /* check if there is more to read */
+        fd_set         perm;
+        int            fds, ret, loopc;
+        struct timeval timeout;
+
+        FD_ZERO(&perm);
+        FD_SET(s, &perm);
+        fds = s +1;
+
+        timeout.tv_sec  = 1;
+        timeout.tv_usec = 0;
+        loopc = 0;
+        while( select (fds, &perm, NULL, NULL, &timeout ) >0 ) {
+           if ( FD_ISSET(s, &perm) ) {
+              ret = read(s, rbuf+rc, sizeof(rbuf)-rc);
+              if ( ret<0 ) {
+                 rc = ret;
+                 break;
+              } else {
+                 if (ret == 0) {
+                   loopc += 1;
+                 } else {
+                   loopc = 0;
+                 }
+                 if (loopc > sizeof(rbuf)) { // arbitrary chosen value
+                   break;
+                 }
+                 rc += ret;
+              }
+           }
+        }
+    }
     (void) close(s);			/* we're done with the remote */
     if (rc == -1) {
 	syslog(LOG_WARNING, "auth_rimap: read (response): %m");
Index: cyrus-sasl2-2.1.25.dfsg1/lib/checkpw.c
===================================================================
--- cyrus-sasl2-2.1.25.dfsg1.orig/lib/checkpw.c	2013-05-16 15:36:35.000000000 +0000
+++ cyrus-sasl2-2.1.25.dfsg1/lib/checkpw.c	2013-05-16 15:36:53.000000000 +0000
@@ -587,16 +587,14 @@
 	    /* Timeout. */
 	    errno = ETIMEDOUT;
 	    return -1;
-	case +1:
-	    if (FD_ISSET(fd, &rfds)) {
-		/* Success, file descriptor is readable. */
-		return 0;
-	    }
-	    return -1;
 	case -1:
 	    if (errno == EINTR || errno == EAGAIN)
 		continue;
 	default:
+	    if (FD_ISSET(fd, &rfds)) {
+		/* Success, file descriptor is readable. */
+		return 0;
+	    }
 	    /* Error catch-all. */
 	    return -1;
 	}

Reply via email to