mirror of
https://github.com/systemd/systemd.git
synced 2025-03-31 14:50:15 +03:00
resolved: don't claim DnsQuestion have to have the same names
Wen DnsQuestion objects are used for DnsQuery objects all contained keys have to share the same name, but otherwise they generally don't have to, and this can actually happen in real-life because DnsPacket objects for mDNS use DnsQuestion for the question section. Hence, rename: dns_question_is_valid() to dns_question_is_valid_for_query(), since the name uniqueness check it does is only relevant when used for a query. Similar, rename dns_question_name() to dns_question_first_name(), to be more accurate, as this difference matters if we keys don#t have to share the same name.
This commit is contained in:
parent
ac7653a433
commit
703e4f5e39
@ -38,7 +38,7 @@ static int reply_query_state(DnsQuery *q) {
|
||||
|
||||
name = ip;
|
||||
} else
|
||||
name = dns_question_name(q->question);
|
||||
name = dns_question_first_name(q->question);
|
||||
|
||||
switch (q->state) {
|
||||
|
||||
@ -145,7 +145,7 @@ static void bus_method_resolve_hostname_complete(DnsQuery *q) {
|
||||
|
||||
r = dns_query_process_cname(q);
|
||||
if (r == -ELOOP) {
|
||||
r = sd_bus_reply_method_errorf(q->request, BUS_ERROR_CNAME_LOOP, "CNAME loop detected, or CNAME resolving disabled on '%s'", dns_question_name(q->question));
|
||||
r = sd_bus_reply_method_errorf(q->request, BUS_ERROR_CNAME_LOOP, "CNAME loop detected, or CNAME resolving disabled on '%s'", dns_question_first_name(q->question));
|
||||
goto finish;
|
||||
}
|
||||
if (r < 0)
|
||||
@ -184,7 +184,7 @@ static void bus_method_resolve_hostname_complete(DnsQuery *q) {
|
||||
}
|
||||
|
||||
if (added <= 0) {
|
||||
r = sd_bus_reply_method_errorf(q->request, BUS_ERROR_NO_SUCH_RR, "'%s' does not have any RR of the requested type", dns_question_name(q->question));
|
||||
r = sd_bus_reply_method_errorf(q->request, BUS_ERROR_NO_SUCH_RR, "'%s' does not have any RR of the requested type", dns_question_first_name(q->question));
|
||||
goto finish;
|
||||
}
|
||||
|
||||
@ -466,7 +466,7 @@ static void bus_method_resolve_record_complete(DnsQuery *q) {
|
||||
|
||||
r = dns_query_process_cname(q);
|
||||
if (r == -ELOOP) {
|
||||
r = sd_bus_reply_method_errorf(q->request, BUS_ERROR_CNAME_LOOP, "CNAME loop detected, or CNAME resolving disabled on '%s'", dns_question_name(q->question));
|
||||
r = sd_bus_reply_method_errorf(q->request, BUS_ERROR_CNAME_LOOP, "CNAME loop detected, or CNAME resolving disabled on '%s'", dns_question_first_name(q->question));
|
||||
goto finish;
|
||||
}
|
||||
if (r < 0)
|
||||
@ -502,7 +502,7 @@ static void bus_method_resolve_record_complete(DnsQuery *q) {
|
||||
}
|
||||
|
||||
if (added <= 0) {
|
||||
r = sd_bus_reply_method_errorf(q->request, BUS_ERROR_NO_SUCH_RR, "Name '%s' does not have any RR of the requested type", dns_question_name(q->question));
|
||||
r = sd_bus_reply_method_errorf(q->request, BUS_ERROR_NO_SUCH_RR, "Name '%s' does not have any RR of the requested type", dns_question_first_name(q->question));
|
||||
goto finish;
|
||||
}
|
||||
|
||||
@ -612,7 +612,7 @@ static int append_srv(DnsQuery *q, sd_bus_message *reply, DnsResourceRecord *rr)
|
||||
if (aux->auxiliary_result != 0)
|
||||
continue;
|
||||
|
||||
r = dns_name_equal(dns_question_name(aux->question), rr->srv.name);
|
||||
r = dns_name_equal(dns_question_first_name(aux->question), rr->srv.name);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (r == 0)
|
||||
@ -664,7 +664,7 @@ static int append_srv(DnsQuery *q, sd_bus_message *reply, DnsResourceRecord *rr)
|
||||
if (aux->auxiliary_result != 0)
|
||||
continue;
|
||||
|
||||
r = dns_name_equal(dns_question_name(aux->question), rr->srv.name);
|
||||
r = dns_name_equal(dns_question_first_name(aux->question), rr->srv.name);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (r == 0)
|
||||
@ -773,7 +773,7 @@ static void resolve_service_all_complete(DnsQuery *q) {
|
||||
assert(bad->auxiliary_result != 0);
|
||||
|
||||
if (bad->auxiliary_result == -ELOOP) {
|
||||
r = sd_bus_reply_method_errorf(q->request, BUS_ERROR_CNAME_LOOP, "CNAME loop detected, or CNAME resolving disabled on '%s'", dns_question_name(bad->question));
|
||||
r = sd_bus_reply_method_errorf(q->request, BUS_ERROR_CNAME_LOOP, "CNAME loop detected, or CNAME resolving disabled on '%s'", dns_question_first_name(bad->question));
|
||||
goto finish;
|
||||
}
|
||||
|
||||
@ -818,7 +818,7 @@ static void resolve_service_all_complete(DnsQuery *q) {
|
||||
}
|
||||
|
||||
if (added <= 0) {
|
||||
r = sd_bus_reply_method_errorf(q->request, BUS_ERROR_NO_SUCH_RR, "'%s' does not have any RR of the requested type", dns_question_name(q->question));
|
||||
r = sd_bus_reply_method_errorf(q->request, BUS_ERROR_NO_SUCH_RR, "'%s' does not have any RR of the requested type", dns_question_first_name(q->question));
|
||||
goto finish;
|
||||
}
|
||||
|
||||
@ -957,7 +957,7 @@ static void bus_method_resolve_service_complete(DnsQuery *q) {
|
||||
|
||||
r = dns_query_process_cname(q);
|
||||
if (r == -ELOOP) {
|
||||
r = sd_bus_reply_method_errorf(q->request, BUS_ERROR_CNAME_LOOP, "CNAME loop detected, or CNAME resolving disabled on '%s'", dns_question_name(q->question));
|
||||
r = sd_bus_reply_method_errorf(q->request, BUS_ERROR_CNAME_LOOP, "CNAME loop detected, or CNAME resolving disabled on '%s'", dns_question_first_name(q->question));
|
||||
goto finish;
|
||||
}
|
||||
if (r < 0)
|
||||
@ -993,7 +993,7 @@ static void bus_method_resolve_service_complete(DnsQuery *q) {
|
||||
}
|
||||
|
||||
if (found <= 0) {
|
||||
r = sd_bus_reply_method_errorf(q->request, BUS_ERROR_NO_SUCH_RR, "'%s' does not have any RR of the requested type", dns_question_name(q->question));
|
||||
r = sd_bus_reply_method_errorf(q->request, BUS_ERROR_NO_SUCH_RR, "'%s' does not have any RR of the requested type", dns_question_first_name(q->question));
|
||||
goto finish;
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ int dns_query_new(Manager *m, DnsQuery **ret, DnsQuestion *question, int ifindex
|
||||
assert(m);
|
||||
assert(question);
|
||||
|
||||
r = dns_question_is_valid(question);
|
||||
r = dns_question_is_valid_for_query(question);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@ -655,7 +655,7 @@ int dns_query_go(DnsQuery *q) {
|
||||
assert(q->question);
|
||||
assert(q->question->n_keys > 0);
|
||||
|
||||
name = dns_question_name(q->question);
|
||||
name = dns_question_first_name(q->question);
|
||||
|
||||
LIST_FOREACH(scopes, s, q->manager->dns_scopes) {
|
||||
DnsScopeMatch match;
|
||||
|
@ -125,7 +125,7 @@ int dns_question_matches_cname(DnsQuestion *q, DnsResourceRecord *rr) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dns_question_is_valid(DnsQuestion *q) {
|
||||
int dns_question_is_valid_for_query(DnsQuestion *q) {
|
||||
const char *name;
|
||||
unsigned i;
|
||||
int r;
|
||||
@ -274,8 +274,10 @@ int dns_question_cname_redirect(DnsQuestion *q, const DnsResourceRecord *cname,
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char *dns_question_name(DnsQuestion *q) {
|
||||
assert(q);
|
||||
const char *dns_question_first_name(DnsQuestion *q) {
|
||||
|
||||
if (!q)
|
||||
return NULL;
|
||||
|
||||
if (q->n_keys < 1)
|
||||
return NULL;
|
||||
|
@ -25,7 +25,7 @@ typedef struct DnsQuestion DnsQuestion;
|
||||
|
||||
#include "resolved-dns-rr.h"
|
||||
|
||||
/* A simple array of resources keys, all sharing the same domain */
|
||||
/* A simple array of resources keys */
|
||||
|
||||
struct DnsQuestion {
|
||||
unsigned n_ref;
|
||||
@ -45,12 +45,12 @@ int dns_question_add(DnsQuestion *q, DnsResourceKey *key);
|
||||
|
||||
int dns_question_matches_rr(DnsQuestion *q, DnsResourceRecord *rr);
|
||||
int dns_question_matches_cname(DnsQuestion *q, DnsResourceRecord *rr);
|
||||
int dns_question_is_valid(DnsQuestion *q);
|
||||
int dns_question_is_valid_for_query(DnsQuestion *q);
|
||||
int dns_question_contains(DnsQuestion *a, DnsResourceKey *k);
|
||||
int dns_question_is_equal(DnsQuestion *a, DnsQuestion *b);
|
||||
|
||||
int dns_question_cname_redirect(DnsQuestion *q, const DnsResourceRecord *cname, DnsQuestion **ret);
|
||||
|
||||
const char *dns_question_name(DnsQuestion *q);
|
||||
const char *dns_question_first_name(DnsQuestion *q);
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(DnsQuestion*, dns_question_unref);
|
||||
|
Loading…
x
Reference in New Issue
Block a user