Fix dovecot with empty 334 challenge.
[exim.git] / src / src / auths / dovecot.c
index 032a089cad9876fe94dab4ca5e0877b01dadd4eb..94b315209918dfc184fe8124903a418ff1a6a35d 100644 (file)
@@ -118,7 +118,6 @@ static int
 strcut(uschar *str, uschar **ptrs, int nptrs)
 {
        uschar *last_sub_start = str;
-       uschar *lastvalid = str + Ustrlen(str);
        int n;
 
        for (n = 0; n < nptrs; n++)
@@ -137,16 +136,14 @@ strcut(uschar *str, uschar **ptrs, int nptrs)
                str++;
        }
 
-       if (last_sub_start < lastvalid) {
-              if (n <= nptrs) {
-                       *ptrs = last_sub_start;
-               } else {
-                       HDEBUG(D_auth) debug_printf("dovecot: warning: too many results from tab-splitting; saw %d fields, room for %d\n", n, nptrs);
-                       n = nptrs;
-              }
+       /* It's acceptable for the string to end with a tab character.  We see
+       this in AUTH PLAIN without an initial response from the client, which
+       causing us to send "334 " and get the data from the client. */
+       if (n <= nptrs) {
+               *ptrs = last_sub_start;
        } else {
-              n--;
-              HDEBUG(D_auth) debug_printf("dovecot: warning: ignoring trailing tab\n");
+               HDEBUG(D_auth) debug_printf("dovecot: warning: too many results from tab-splitting; saw %d fields, room for %d\n", n, nptrs);
+               n = nptrs;
        }
 
        return n <= nptrs ? n : nptrs;