X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fresolve%2Fresolved-dns-scope.c;h=f1de9bc2eb65ca1fada7d19afb714a01020a8f37;hb=d84b686f06a7f724c12dcace0ab5cb82d01885f9;hp=8d03049c103aec8e3eb867faa5533b2cb8046176;hpb=7b4c2ee75faf08b7a415337b46efc670f986128a;p=elogind.git diff --git a/src/resolve/resolved-dns-scope.c b/src/resolve/resolved-dns-scope.c index 8d03049c1..f1de9bc2e 100644 --- a/src/resolve/resolved-dns-scope.c +++ b/src/resolve/resolved-dns-scope.c @@ -412,7 +412,9 @@ static int dns_scope_make_reply_packet( assert(s); - if (q->n_keys <= 0 && answer->n_rrs <= 0 && soa->n_rrs <= 0) + if ((!q || q->n_keys <= 0) + && (!answer || answer->n_rrs <= 0) + && (!soa || soa->n_rrs <= 0)) return -EINVAL; r = dns_packet_new(&p, s->protocol, 0); @@ -544,7 +546,7 @@ void dns_scope_process_query(DnsScope *s, DnsStream *stream, DnsPacket *p) { } } -DnsTransaction *dns_scope_find_transaction(DnsScope *scope, DnsQuestion *question) { +DnsTransaction *dns_scope_find_transaction(DnsScope *scope, DnsQuestion *question, bool cache_ok) { DnsTransaction *t; assert(scope); @@ -553,9 +555,19 @@ DnsTransaction *dns_scope_find_transaction(DnsScope *scope, DnsQuestion *questio /* Try to find an ongoing transaction that is a equal or a * superset of the specified question */ - LIST_FOREACH(transactions_by_scope, t, scope->transactions) + LIST_FOREACH(transactions_by_scope, t, scope->transactions) { + + /* Refuse reusing transactions that completed based on + * cached data instead of a real packet, if that's + * requested. */ + if (!cache_ok && + IN_SET(t->state, DNS_TRANSACTION_SUCCESS, DNS_TRANSACTION_FAILURE) && + !t->received) + continue; + if (dns_question_is_superset(t->question, question) > 0) return t; + } return NULL; }