aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Andree <matthias.andree@gmx.de>2007-03-29 22:21:25 +0000
committerMatthias Andree <matthias.andree@gmx.de>2007-03-29 22:21:25 +0000
commit0429d4e16b5db4e59f1fa926416e346c6e879ca5 (patch)
tree26baa24ce11e78d16b668f0393aa8de90d39c254
parentf213cba8d7f7ca22de9d4feba32ac522c8d04b91 (diff)
downloadfetchmail-0429d4e16b5db4e59f1fa926416e346c6e879ca5.tar.gz
fetchmail-0429d4e16b5db4e59f1fa926416e346c6e879ca5.tar.bz2
fetchmail-0429d4e16b5db4e59f1fa926416e346c6e879ca5.zip
Do not crash with a null pointer dereference when opening the BSMTP file
fails. Improve error checking and reporting. Reported by Reto Schttel, Debian Bug#416625. Fix based on a patch by Nico Golde. svn path=/branches/BRANCH_6-3/; revision=5070
-rw-r--r--NEWS3
-rw-r--r--sink.c10
2 files changed, 11 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index 2a75864f..1b79f5e5 100644
--- a/NEWS
+++ b/NEWS
@@ -74,6 +74,9 @@ fetchmail 6.3.8 (not yet released):
Reported by Nico Golde.
* If SOCKS support was compiled in, add 'socks' to the feature_options Python
list emitted in --configdump. Reported by Rob MacGregor.
+* Do not crash with a null pointer dereference when opening the BSMTP file
+ fails. Improve error checking and reporting. Reported by Reto Schüttel,
+ Debian Bug#416625. Fix based on a patch by Nico Golde.
# DOCUMENTATION:
* Extend --mda documentation, discourage use of qmail-inject.
diff --git a/sink.c b/sink.c
index 92477ef9..22d2243a 100644
--- a/sink.c
+++ b/sink.c
@@ -708,6 +708,12 @@ static int open_bsmtp_sink(struct query *ctl, struct msgblk *msg,
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 @@ static int open_bsmtp_sink(struct query *ctl, struct msgblk *msg,
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);
}