File imap-2006c1-rfc822_output_char_dos.patch of Package imap

Index: src/c-client/rfc822.c
===================================================================
--- src/c-client/rfc822.c.orig
+++ src/c-client/rfc822.c
@@ -1322,6 +1322,7 @@ char *rfc822_skip_comment (char **s,long
 
 static long rfc822_output_char (RFC822BUFFER *buf,int c)
 {
+  if ((buf->cur == buf->end) && !rfc822_output_flush (buf)) return NIL;
   *buf->cur++ = c;		/* add character, soutr buffer if full */
   return (buf->cur == buf->end) ? rfc822_output_flush (buf) : LONGT;
 }
@@ -1345,7 +1346,8 @@ static long rfc822_output_data (RFC822BU
       len -= i;
     }
 				/* soutr buffer now if full */
-    if (len && !rfc822_output_flush (buf)) return NIL;
+    if ((len || (buf->cur == buf->end)) && !rfc822_output_flush (buf))
+      return NIL;
   }
   return LONGT;
 }