From 6507df718f47e39a0ed1ecfabba648d1bb9ba538 Mon Sep 17 00:00:00 2001 From: gilles Date: Fri, 9 Oct 2015 15:09:09 +0000 Subject: [PATCH] if an error occurs during offline enqueuing after we've dropped group, then attempt to ftruncate() the fp back to 0. suggested and ok millert@, ok eric@ --- usr.sbin/smtpd/enqueue.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/usr.sbin/smtpd/enqueue.c b/usr.sbin/smtpd/enqueue.c index cd65e34aa17..d05bbd89149 100644 --- a/usr.sbin/smtpd/enqueue.c +++ b/usr.sbin/smtpd/enqueue.c @@ -1,4 +1,4 @@ -/* $OpenBSD: enqueue.c,v 1.97 2015/10/09 14:37:38 gilles Exp $ */ +/* $OpenBSD: enqueue.c,v 1.98 2015/10/09 15:09:09 gilles Exp $ */ /* * Copyright (c) 2005 Henning Brauer @@ -811,6 +811,7 @@ enqueue_offline(int argc, char *argv[], FILE *ifile, FILE *ofile) for (i = 1; i < argc; i++) { if (strchr(argv[i], '|') != NULL) { warnx("%s contains illegal character", argv[i]); + ftruncate(fileno(ofile), 0); exit(EX_SOFTWARE); } fprintf(ofile, "%s%s", i == 1 ? "" : "|", argv[i]); @@ -821,11 +822,13 @@ enqueue_offline(int argc, char *argv[], FILE *ifile, FILE *ofile) while ((ch = fgetc(ifile)) != EOF) if (fputc(ch, ofile) == EOF) { warn("write error"); + ftruncate(fileno(ofile), 0); exit(EX_UNAVAILABLE); } if (ferror(ifile)) { warn("read error"); + ftruncate(fileno(ofile), 0); exit(EX_UNAVAILABLE); } -- 2.20.1