summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacek Masiulaniec <jacekm@cvs.openbsd.org>2009-09-04 11:44:24 +0000
committerJacek Masiulaniec <jacekm@cvs.openbsd.org>2009-09-04 11:44:24 +0000
commitb61e4f581dc2071fa5ca2f5cf7bc0903e21b9efe (patch)
tree5ea8180b8e5dd3c3cc6553908ee447da87811ba2
parent65b93c258bf156ae4199603a900a7d1106018b97 (diff)
Fix a crash when messagep->batch_id is read from disk and used long
after the batch has ceased to exist. From gilles@
-rw-r--r--usr.sbin/smtpd/queue_shared.c8
-rw-r--r--usr.sbin/smtpd/runner.c5
2 files changed, 10 insertions, 3 deletions
diff --git a/usr.sbin/smtpd/queue_shared.c b/usr.sbin/smtpd/queue_shared.c
index 75425d2b1a5..dc02b120d60 100644
--- a/usr.sbin/smtpd/queue_shared.c
+++ b/usr.sbin/smtpd/queue_shared.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: queue_shared.c,v 1.22 2009/08/08 23:02:43 gilles Exp $ */
+/* $OpenBSD: queue_shared.c,v 1.23 2009/09/04 11:44:23 jacekm Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -494,6 +494,10 @@ queue_update_envelope(struct message *messagep)
char temp[MAXPATHLEN];
char dest[MAXPATHLEN];
FILE *fp;
+ u_int64_t batch_id;
+
+ batch_id = messagep->batch_id;
+ messagep->batch_id = 0;
if (! bsnprintf(temp, sizeof(temp), "%s/envelope.tmp", PATH_QUEUE))
fatalx("queue_update_envelope");
@@ -523,6 +527,7 @@ queue_update_envelope(struct message *messagep)
fatal("queue_update_envelope: rename");
}
+ messagep->batch_id = batch_id;
return 1;
tempfail:
@@ -531,6 +536,7 @@ tempfail:
if (fp)
fclose(fp);
+ messagep->batch_id = batch_id;
return 0;
}
diff --git a/usr.sbin/smtpd/runner.c b/usr.sbin/smtpd/runner.c
index a08fbe0196c..59fd7345022 100644
--- a/usr.sbin/smtpd/runner.c
+++ b/usr.sbin/smtpd/runner.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: runner.c,v 1.64 2009/09/03 08:19:13 jacekm Exp $ */
+/* $OpenBSD: runner.c,v 1.65 2009/09/04 11:44:23 jacekm Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -695,6 +695,7 @@ runner_process_runqueue(struct smtpd *env)
fatal("runner_process_runqueue: calloc");
*messagep = message;
+ messagep->batch_id = 0;
batchp = batch_lookup(env, messagep);
if (batchp != NULL)
messagep->batch_id = batchp->id;
@@ -1000,7 +1001,7 @@ batch_lookup(struct smtpd *env, struct message *message)
/* We only support delivery of one message at a time, in MDA
* and bounces messages.
*/
- if (message->type & (T_BOUNCE_MESSAGE|T_MDA_MESSAGE))
+ if (message->type == T_BOUNCE_MESSAGE || message->type == T_MDA_MESSAGE)
return NULL;
/* If message->batch_id != 0, we can retrieve batch by id */