summaryrefslogtreecommitdiff
path: root/usr.sbin/smtpd
diff options
context:
space:
mode:
authorEric Faurot <eric@cvs.openbsd.org>2012-10-08 08:46:25 +0000
committerEric Faurot <eric@cvs.openbsd.org>2012-10-08 08:46:25 +0000
commitaa6fcfc35259649b01e33dcaa869d28c482d2397 (patch)
treea18ec0356e809f0224575c6ac2df3d6b95f20f3c /usr.sbin/smtpd
parent4192029e5ecb68b6789deb00ece72a8d42c91c4b (diff)
skip RR if type is not MX. Use hostname if the list of MX is empty
after the loop. spotted by huku at grhack.net ok gilles@
Diffstat (limited to 'usr.sbin/smtpd')
-rw-r--r--usr.sbin/smtpd/dns.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/usr.sbin/smtpd/dns.c b/usr.sbin/smtpd/dns.c
index b9be2835ffb..3d00e4ee223 100644
--- a/usr.sbin/smtpd/dns.c
+++ b/usr.sbin/smtpd/dns.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dns.c,v 1.59 2012/10/03 21:44:35 gilles Exp $ */
+/* $OpenBSD: dns.c,v 1.60 2012/10/08 08:46:24 eric Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -254,12 +254,10 @@ dns_asr_dispatch_mx(struct dnssession *s)
unpack_header(&pack, &h);
unpack_query(&pack, &q);
- if (h.ancount == 0)
- /* fallback to host if no MX is found. */
- dnssession_mx_insert(s, query->host, 0);
-
for (; h.ancount; h.ancount--) {
unpack_rr(&pack, &rr);
+ if (rr.rr_type != T_MX)
+ continue;
print_dname(rr.rr.mx.exchange, buf, sizeof(buf));
buf[strlen(buf) - 1] = '\0';
dnssession_mx_insert(s, buf, rr.rr.mx.preference);
@@ -267,6 +265,10 @@ dns_asr_dispatch_mx(struct dnssession *s)
free(ar.ar_data);
+ /* fallback to host if no MX is found. */
+ if (TAILQ_EMPTY(&s->mx))
+ dnssession_mx_insert(s, query->host, 0);
+
/* Now we have a sorted list of MX to resolve. Simply "turn" this
* MX session into a regular host session.
*/