summaryrefslogtreecommitdiff
path: root/usr.sbin/smtpd
diff options
context:
space:
mode:
authorJacek Masiulaniec <jacekm@cvs.openbsd.org>2008-12-31 09:50:41 +0000
committerJacek Masiulaniec <jacekm@cvs.openbsd.org>2008-12-31 09:50:41 +0000
commit7272e31a2e9fb958752a691eed2b9e357570e38b (patch)
tree600b671db4e2f195a3909cbb86c29238f939f047 /usr.sbin/smtpd
parentcacdc6f30cf3440adb1f7aa61397801c8422bf55 (diff)
rename may fail due to ENOSPC, make smtpd survive this condition; ok gilles@
Diffstat (limited to 'usr.sbin/smtpd')
-rw-r--r--usr.sbin/smtpd/queue.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/usr.sbin/smtpd/queue.c b/usr.sbin/smtpd/queue.c
index bdfb573fd9b..4250cab3c3e 100644
--- a/usr.sbin/smtpd/queue.c
+++ b/usr.sbin/smtpd/queue.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: queue.c,v 1.37 2008/12/31 09:47:11 jacekm Exp $ */
+/* $OpenBSD: queue.c,v 1.38 2008/12/31 09:50:40 jacekm Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -815,15 +815,13 @@ queue_commit_incoming_message(struct message *messagep)
{
char rootdir[MAXPATHLEN];
char queuedir[MAXPATHLEN];
- u_int16_t hval;
if (! bsnprintf(rootdir, MAXPATHLEN, "%s/%s", PATH_INCOMING,
messagep->message_id))
fatal("queue_commit_message_incoming: snprintf");
- hval = queue_hash(messagep->message_id);
-
- if (! bsnprintf(queuedir, MAXPATHLEN, "%s/%d", PATH_QUEUE, hval))
+ if (! bsnprintf(queuedir, MAXPATHLEN, "%s/%d", PATH_QUEUE,
+ queue_hash(messagep->message_id)))
fatal("queue_commit_message_incoming: snprintf");
if (mkdir(queuedir, 0700) == -1) {
@@ -833,13 +831,15 @@ queue_commit_incoming_message(struct message *messagep)
fatal("queue_commit_message_incoming: mkdir");
}
- if (! bsnprintf(queuedir, MAXPATHLEN, "%s/%d/%s", PATH_QUEUE, hval,
- messagep->message_id))
- fatal("queue_commit_message_incoming: snprintf");
-
+ if (strlcat(queuedir, "/", MAXPATHLEN) >= MAXPATHLEN ||
+ strlcat(queuedir, messagep->message_id, MAXPATHLEN) >= MAXPATHLEN)
+ fatalx("queue_commit_incoming_message: truncation");
- if (rename(rootdir, queuedir) == -1)
+ if (rename(rootdir, queuedir) == -1) {
+ if (errno == ENOSPC)
+ return 0;
fatal("queue_commit_message_incoming: rename");
+ }
return 1;
}