aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2026-02-10 10:51:24 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2026-02-10 10:51:24 +0000
commitef5f89682886a7ab6cdb5b56d009d839a173b197 (patch)
treef225ecde8ef3047af39da01c4849f2f9c615bec9
parent5c8ed81bf50cb7d51efc2fef17c1ae8bb457c171 (diff)
downloadsmtpd-starttls-proxy-ef5f89682886a7ab6cdb5b56d009d839a173b197.tar.gz
Unqualify MX names because X509 is dumb?
-rw-r--r--src/qmail-remote/dns.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/qmail-remote/dns.c b/src/qmail-remote/dns.c
index 4970ec4..9054b2d 100644
--- a/src/qmail-remote/dns.c
+++ b/src/qmail-remote/dns.c
@@ -58,6 +58,7 @@ static unsigned int use_host_as_mx (skadns_t *a, char const *host, genalloc *mxi
qmailr_tempusys("DNS-encode host domain") ;
info.pos = storage->len ;
if (!stralloc_catb(storage, host, hostlen+1)) dienomem() ;
+ if (hostlen > 1 && storage->s[storage->len - 2] == '.') storage->s[--storage->len - 1] = 0 ;
if (!skadns_send_g(a, &info.id4, &q, S6DNS_T_A, deadline, deadline))
qmailr_tempusys("send ", "A", " DNS query") ;
LOLDEBUG("sending A for %s, id %hu", host, info.id4) ;
@@ -194,7 +195,9 @@ unsigned int dns_stuff (char const *host, char const *const *eaddr, unsigned int
p->pos = storage->len ;
len = s6dns_domain_tostring(storage->s + p->pos, 256, &mxs[i].exchange) ;
if (!len) qmailr_perm("invalid MX name") ;
- storage->len += len ; storage->s[storage->len++] = 0 ;
+ storage->len += len ;
+ if (storage->s[storage->len - 1] == '.') storage->len-- ;
+ storage->s[storage->len++] = 0 ;
p->ip4 = p->ip6 = stralloc_zero ;
s6dns_domain_encode(&mxs[i].exchange) ;
if (!skadns_send_g(&a, &p->id4, &mxs[i].exchange, S6DNS_T_A, &deadline, &deadline))