From 6b142b3a1d007d7e6f50c26710de7177bc4aca74 Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Mon, 8 Jun 2015 15:21:18 +0200 Subject: Record TTL also for DNS PTR queries (bug 18513) This allows nscd to manage proper TTL for GETHOSTBYADDR[v6] requests. --- resolv/nss_dns/dns-host.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'resolv') diff --git a/resolv/nss_dns/dns-host.c b/resolv/nss_dns/dns-host.c index d8c5579..357ac04 100644 --- a/resolv/nss_dns/dns-host.c +++ b/resolv/nss_dns/dns-host.c @@ -800,6 +800,10 @@ getanswer_r (const querybuf *answer, int anslen, const char *qname, int qtype, if (qtype == T_PTR && type == T_CNAME) { + /* A CNAME could also have a TTL entry. */ + if (ttlp != NULL && ttl < *ttlp) + *ttlp = ttl; + n = dn_expand (answer->buf, end_of_message, cp, tbuf, sizeof tbuf); if (__glibc_unlikely (n < 0 || res_dnok (tbuf) == 0)) { @@ -863,6 +867,8 @@ getanswer_r (const querybuf *answer, int anslen, const char *qname, int qtype, ++had_error; break; } + if (ttlp != NULL && ttl < *ttlp) + *ttlp = ttl; /* bind would put multiple PTR records as aliases, but we don't do that. */ result->h_name = bp; -- cgit v1.1