summaryrefslogtreecommitdiff
path: root/usr.sbin/smtpd
diff options
context:
space:
mode:
authorEric Faurot <eric@cvs.openbsd.org>2013-11-06 10:07:30 +0000
committerEric Faurot <eric@cvs.openbsd.org>2013-11-06 10:07:30 +0000
commit2a518a9af63ee7fd9ea6425e7f4fc1328768333f (patch)
tree37efb004a22b9c36c5204188478f85d6864ea8bd /usr.sbin/smtpd
parent0960f1497adeed8214c7f1943c6de212fb3a594f (diff)
fix assertion that could lead to orphaned messages left in the queue
after all envelopes are gone.
Diffstat (limited to 'usr.sbin/smtpd')
-rw-r--r--usr.sbin/smtpd/queue_fs.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/usr.sbin/smtpd/queue_fs.c b/usr.sbin/smtpd/queue_fs.c
index 5530312d726..d00b1208d3b 100644
--- a/usr.sbin/smtpd/queue_fs.c
+++ b/usr.sbin/smtpd/queue_fs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: queue_fs.c,v 1.2 2013/10/26 12:27:59 eric Exp $ */
+/* $OpenBSD: queue_fs.c,v 1.3 2013/11/06 10:07:29 eric Exp $ */
/*
* Copyright (c) 2011 Gilles Chehade <gilles@poolp.org>
@@ -72,6 +72,8 @@ static void fsqueue_qwalk_close(void *);
struct tree evpcount;
static struct timespec startup;
+#define REF (int*)0xf00
+
static int
queue_fs_message_create(uint32_t *msgid)
{
@@ -235,9 +237,8 @@ queue_fs_envelope_create(uint32_t msgid, const char *buf, size_t len,
uint64_t *evpid)
{
char path[SMTPD_MAXPATHLEN];
- int queued = 0, i, r = 0;
+ int queued = 0, i, r = 0, *n;
struct stat sb;
- uintptr_t *n;
if (msgid == 0) {
log_warnx("warn: queue-fs: msgid=0, evpid=%016"PRIx64, *evpid);
@@ -267,7 +268,7 @@ done:
if (r) {
n = tree_pop(&evpcount, msgid);
if (n == NULL)
- n = 0;
+ n = REF;
n += 1;
tree_xset(&evpcount, msgid, n);
}
@@ -319,7 +320,7 @@ queue_fs_envelope_delete(uint64_t evpid)
{
char pathname[SMTPD_MAXPATHLEN];
uint32_t msgid;
- uintptr_t *n;
+ int *n;
fsqueue_envelope_path(evpid, pathname, sizeof(pathname));
if (unlink(pathname) == -1)
@@ -330,7 +331,7 @@ queue_fs_envelope_delete(uint64_t evpid)
n = tree_pop(&evpcount, msgid);
n -= 1;
- if ((uintptr_t)n == 0)
+ if (n - REF == 0)
queue_fs_message_delete(msgid);
else
tree_xset(&evpcount, msgid, n);
@@ -343,8 +344,7 @@ queue_fs_envelope_walk(uint64_t *evpid, char *buf, size_t len)
{
static int done = 0;
static void *hdl = NULL;
- uintptr_t *n;
- int r;
+ int r, *n;
uint32_t msgid;
if (done)
@@ -359,6 +359,8 @@ queue_fs_envelope_walk(uint64_t *evpid, char *buf, size_t len)
if (r) {
msgid = evpid_to_msgid(*evpid);
n = tree_pop(&evpcount, msgid);
+ if (n == NULL)
+ n = REF;
n += 1;
tree_xset(&evpcount, msgid, n);
}