Nico Golde schrieb am 2007-03-29:

> the attached patch fixes #416625 in Debian.

And removes the error check after writing the DATA line - reinstated,
fflush() added, clarified error messages (sorry this takes another
translation run). I've merged a different patch (attached). Back out
yours first. Still, thank you for forwarding the report and the
suggested fix.

BTW, has anyone ever used BSMTP? It failed for me with PS_SOCKET after
writing the first header, no matter if I used IMAP or POP3 with --all.
The attached patch should fix that as well. (First hunk.)

-- 
Matthias Andree
Index: sink.c
===================================================================
--- sink.c      (Revision 5069)
+++ sink.c      (Revision 5071)
@@ -686,7 +686,7 @@
 
     n = 0;
     if (ctl->mda || ctl->bsmtp) {
-       n = fwrite(buf, last - buf, 1, sinkfp);
+       n = fwrite(buf, 1, last - buf, sinkfp);
        if (ferror(sinkfp)) n = -1;
     } else if (ctl->smtp_socket != -1)
        n = SockWrite(ctl->smtp_socket, buf, last - buf);
@@ -708,6 +708,12 @@
     else
        sinkfp = fopen(ctl->bsmtp, "a");
 
+    if (!sinkfp || ferror(sinkfp)) {
+       report(stderr, GT_("BSMTP file open failed: %s\n"), 
+               strerror(errno));
+        return(PS_BSMTP);
+    }
+
     /* see the ap computation under the SMTP branch */
     need_anglebrs = (msg->return_path[0] != '<');
     fprintf(sinkfp,
@@ -747,9 +753,9 @@
 
     fputs("DATA\r\n", sinkfp);
 
-    if (ferror(sinkfp))
+    if (fflush(sinkfp) || ferror(sinkfp))
     {
-       report(stderr, GT_("BSMTP file open or preamble write failed\n"));
+       report(stderr, GT_("BSMTP preamble write failed.\n"));
        return(PS_BSMTP);
     }
 

Reply via email to