diff options
| author | 2012-01-14 10:48:47 +0000 | |
|---|---|---|
| committer | 2012-01-14 10:48:47 +0000 | |
| commit | 9bb76401d5433d65720a4f6e6694dd28f262811e (patch) | |
| tree | 16d605aeb4b06b1bec7c51584c7390214c61c458 /usr.sbin/smtpd/queue_fsqueue.c | |
| parent | KNF whitespace; no change with diff -w (diff) | |
| download | wireguard-openbsd-9bb76401d5433d65720a4f6e6694dd28f262811e.tar.xz wireguard-openbsd-9bb76401d5433d65720a4f6e6694dd28f262811e.zip | |
When creating a new message (in incoming/) make sure that the msgid does not
already exist in queue/ to prevent possible collision on commit.
ok gilles@
Diffstat (limited to 'usr.sbin/smtpd/queue_fsqueue.c')
| -rw-r--r-- | usr.sbin/smtpd/queue_fsqueue.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/usr.sbin/smtpd/queue_fsqueue.c b/usr.sbin/smtpd/queue_fsqueue.c index 0737140a132..ecbe691e985 100644 --- a/usr.sbin/smtpd/queue_fsqueue.c +++ b/usr.sbin/smtpd/queue_fsqueue.c @@ -1,4 +1,4 @@ -/* $OpenBSD: queue_fsqueue.c,v 1.31 2012/01/14 08:37:16 eric Exp $ */ +/* $OpenBSD: queue_fsqueue.c,v 1.32 2012/01/14 10:48:47 eric Exp $ */ /* * Copyright (c) 2011 Gilles Chehade <gilles@openbsd.org> @@ -268,11 +268,17 @@ fsqueue_message_create(enum queue_kind qkind, u_int32_t *msgid) { char rootdir[MAXPATHLEN]; char evpdir[MAXPATHLEN]; + struct stat sb; again: *msgid = queue_generate_msgid(); - fsqueue_message_path(qkind, *msgid, rootdir, sizeof(rootdir)); + + /* prevent possible collision later when moving to Q_QUEUE */ + fsqueue_message_path(Q_QUEUE, *msgid, rootdir, sizeof(rootdir)); + if (stat(rootdir, &sb) != -1 || errno != ENOENT) + goto again; + fsqueue_message_path(qkind, *msgid, rootdir, sizeof(rootdir)); if (mkdir(rootdir, 0700) == -1) { if (errno == EEXIST) goto again; |
