summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorGilles Chehade <gilles@cvs.openbsd.org>2008-12-07 03:14:25 +0000
committerGilles Chehade <gilles@cvs.openbsd.org>2008-12-07 03:14:25 +0000
commit33e2c35d0e9d5f2219fea94e3aa9aa816f2af7a5 (patch)
tree72651b508da66742dd6308b18e5f12945673214e /usr.sbin
parent1175b367c77957b9c14d4c9527b4f111b9c8d63d (diff)
- getaddrinfo() uses negative values for its error defines, our use of an
u_int8_t to hold the value leads to invalid checking in runner_batch_resolved(), this lead to a crash in MTA because we assumed a batch had its mx resolved when it had not. while at it, be more strict about errors we don't know and fatal(), it should not happen. ok jacekm@, ok chl@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/smtpd/runner.c11
-rw-r--r--usr.sbin/smtpd/smtpd.h4
2 files changed, 9 insertions, 6 deletions
diff --git a/usr.sbin/smtpd/runner.c b/usr.sbin/smtpd/runner.c
index 5374dab1aae..277230ed45a 100644
--- a/usr.sbin/smtpd/runner.c
+++ b/usr.sbin/smtpd/runner.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: runner.c,v 1.3 2008/12/07 01:55:41 gilles Exp $ */
+/* $OpenBSD: runner.c,v 1.4 2008/12/07 03:14:24 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -673,6 +673,11 @@ runner_batch_resolved(struct smtpd *env, struct batch *lookup)
*/
switch (batchp->getaddrinfo_error) {
+ case 0:
+ batchp->flags |= F_BATCH_RESOLVED;
+ for (i = 0; i < batchp->mx_cnt; ++i)
+ batchp->mxarray[i].ss = lookup->mxarray[i].ss;
+ break;
case EAI_ADDRFAMILY:
case EAI_BADFLAGS:
case EAI_BADHINTS:
@@ -704,9 +709,7 @@ runner_batch_resolved(struct smtpd *env, struct batch *lookup)
return 0;
default:
- batchp->flags |= F_BATCH_RESOLVED;
- for (i = 0; i < batchp->mx_cnt; ++i)
- batchp->mxarray[i].ss = lookup->mxarray[i].ss;
+ fatalx("runner_batch_resolved: unknown getaddrinfo error.");
}
return 1;
}
diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h
index 8b879f74630..cdeb4729c10 100644
--- a/usr.sbin/smtpd/smtpd.h
+++ b/usr.sbin/smtpd/smtpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpd.h,v 1.21 2008/12/06 15:18:36 weerd Exp $ */
+/* $OpenBSD: smtpd.h,v 1.22 2008/12/07 03:14:24 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -518,7 +518,7 @@ struct batch {
char hostname[MAXHOSTNAMELEN];
char errorline[MAX_LINE_SIZE];
- u_int8_t getaddrinfo_error;
+ int8_t getaddrinfo_error;
struct mxhost mxarray[MXARRAYSIZE*2];
u_int8_t mx_cnt;
u_int8_t mx_off;