summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorGilles Chehade <gilles@cvs.openbsd.org>2011-04-15 17:30:24 +0000
committerGilles Chehade <gilles@cvs.openbsd.org>2011-04-15 17:30:24 +0000
commita79e70367af7f25159609b27418c3fbd269d02fd (patch)
tree7c92690a06c04ce7d65f7f67573ca815bdbae714 /usr.sbin
parente7348bdd1f5036e8bd812b2296adecb4e2e011e2 (diff)
teach walk_queue() about the new disk-queue layout
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/smtpd/queue_shared.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/usr.sbin/smtpd/queue_shared.c b/usr.sbin/smtpd/queue_shared.c
index ef53b026b60..12f17bfd2c3 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.44 2011/04/15 17:01:05 gilles Exp $ */
+/* $OpenBSD: queue_shared.c,v 1.45 2011/04/15 17:30:23 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -211,23 +211,28 @@ walk_simple(struct qwalk *q, char *fname)
int
walk_queue(struct qwalk *q, char *fname)
{
- const char *errstr;
+ char *ep;
switch (q->level) {
case 0:
if (strcmp(fname, "envelope.tmp") == 0)
return (QWALK_AGAIN);
- q->bucket = strtonum(fname, 0, DIRHASH_BUCKETS - 1, &errstr);
- if (errstr) {
+
+ q->bucket = strtoul(fname, &ep, 16);
+ if (fname[0] == '\0' || *ep != '\0') {
+ log_warnx("walk_queue: invalid bucket: %s", fname);
+ return (QWALK_AGAIN);
+ }
+ if (errno == ERANGE || q->bucket >= DIRHASH_BUCKETS - 1) {
log_warnx("walk_queue: invalid bucket: %s", fname);
return (QWALK_AGAIN);
}
- if (! bsnprintf(q->path, sizeof(q->path), "%s/%d", PATH_QUEUE,
+ if (! bsnprintf(q->path, sizeof(q->path), "%s/%04x", PATH_QUEUE,
q->bucket))
fatalx("walk_queue: snprintf");
return (QWALK_RECURSE);
case 1:
- if (! bsnprintf(q->path, sizeof(q->path), "%s/%d/%s%s",
+ if (! bsnprintf(q->path, sizeof(q->path), "%s/%04x/%s%s",
PATH_QUEUE, q->bucket, fname, PATH_ENVELOPES))
fatalx("walk_queue: snprintf");
return (QWALK_RECURSE);