summaryrefslogtreecommitdiffstats
path: root/contrib/sendmail/mail.local
diff options
context:
space:
mode:
authorgshapiro <gshapiro@FreeBSD.org>2003-02-08 20:31:29 +0000
committergshapiro <gshapiro@FreeBSD.org>2003-02-08 20:31:29 +0000
commit842b56b9cabf175e7842ec5a3b29ff68353b3177 (patch)
tree2e81c43d391ed220f6656502de14ddfbb0de4ecd /contrib/sendmail/mail.local
parent39e311b2e17a53f7ed02fcbe3820ca77b65486d5 (diff)
downloadFreeBSD-src-842b56b9cabf175e7842ec5a3b29ff68353b3177.zip
FreeBSD-src-842b56b9cabf175e7842ec5a3b29ff68353b3177.tar.gz
Import sendmail 8.12.7
Diffstat (limited to 'contrib/sendmail/mail.local')
-rw-r--r--contrib/sendmail/mail.local/mail.local.c31
1 files changed, 28 insertions, 3 deletions
diff --git a/contrib/sendmail/mail.local/mail.local.c b/contrib/sendmail/mail.local/mail.local.c
index 9ef3fb5..027829f 100644
--- a/contrib/sendmail/mail.local/mail.local.c
+++ b/contrib/sendmail/mail.local/mail.local.c
@@ -18,7 +18,7 @@ SM_IDSTR(copyright,
Copyright (c) 1990, 1993, 1994\n\
The Regents of the University of California. All rights reserved.\n")
-SM_IDSTR(id, "@(#)$Id: mail.local.c,v 8.239 2002/05/24 20:56:32 gshapiro Exp $")
+SM_IDSTR(id, "@(#)$Id: mail.local.c,v 8.239.2.2 2002/09/24 02:09:09 ca Exp $")
#include <stdlib.h>
#include <sm/errstring.h>
@@ -657,6 +657,8 @@ store(from, inbody)
(void) sm_strlcpy(tmpbuf, _PATH_LOCTMP, sizeof tmpbuf);
if ((fd = mkstemp(tmpbuf)) < 0 || (fp = fdopen(fd, "w+")) == NULL)
{
+ if (fd >= 0)
+ (void) close(fd);
mailerr("451 4.3.0", "Unable to open temporary file");
return -1;
}
@@ -1200,7 +1202,8 @@ err3:
#ifdef DEBUG
fprintf(stderr, "reset euid = %d\n", (int) geteuid());
#endif /* DEBUG */
- (void) ftruncate(mbfd, curoff);
+ if (mbfd >= 0)
+ (void) ftruncate(mbfd, curoff);
err1: if (mbfd >= 0)
(void) close(mbfd);
err0: unlockmbox();
@@ -1216,7 +1219,29 @@ err0: unlockmbox();
errcode = "552 5.2.2";
#endif /* EDQUOT */
mailerr(errcode, "%s: %s", path, sm_errstring(errno));
- (void) truncate(path, curoff);
+ mbfd = open(path, O_WRONLY|EXTRA_MODE, 0);
+ if (mbfd < 0
+ || fstat(mbfd, &sb) < 0 ||
+ sb.st_nlink != 1 ||
+ !S_ISREG(sb.st_mode) ||
+ sb.st_dev != fsb.st_dev ||
+ sb.st_ino != fsb.st_ino ||
+# if HAS_ST_GEN && 0 /* AFS returns random values for st_gen */
+ sb.st_gen != fsb.st_gen ||
+# endif /* HAS_ST_GEN && 0 */
+ sb.st_uid != fsb.st_uid
+ )
+ {
+ /* Don't use a bogus file */
+ if (mbfd >= 0)
+ {
+ (void) close(mbfd);
+ mbfd = -1;
+ }
+ }
+
+ /* Attempt to truncate back to pre-write size */
+ goto err3;
}
else
notifybiff(biffmsg);
OpenPOWER on IntegriCloud