summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-07-30 17:52:58 +0200
committerLennart Poettering <lennart@poettering.net>2014-07-30 17:53:19 +0200
commit3339cb71d44c5198f9546f113674f06dc7b01a6f (patch)
tree248b06c53cf9c7ffd5717e92d8b34cffc57e1e71
parent79266746741b42da878663faddd1e570f8f38e74 (diff)
resolved: properly pass empty answers back to bus clients
-rw-r--r--src/resolve/resolved-bus.c65
1 files changed, 35 insertions, 30 deletions
diff --git a/src/resolve/resolved-bus.c b/src/resolve/resolved-bus.c
index 1244b6dd07..d0c21894e3 100644
--- a/src/resolve/resolved-bus.c
+++ b/src/resolve/resolved-bus.c
@@ -149,33 +149,36 @@ static void bus_method_resolve_hostname_complete(DnsQuery *q) {
if (r < 0)
goto finish;
- answer = dns_answer_ref(q->answer);
ifindex = q->answer_ifindex;
- for (i = 0; i < answer->n_rrs; i++) {
- r = dns_question_matches_rr(q->question, answer->rrs[i]);
- if (r < 0)
- goto parse_fail;
- if (r == 0) {
- /* Hmm, if this is not an address record,
- maybe it's a cname? If so, remember this */
- r = dns_question_matches_cname(q->question, answer->rrs[i]);
+ if (q->answer) {
+ answer = dns_answer_ref(q->answer);
+
+ for (i = 0; i < answer->n_rrs; i++) {
+ r = dns_question_matches_rr(q->question, answer->rrs[i]);
if (r < 0)
goto parse_fail;
- if (r > 0)
- cname = dns_resource_record_ref(answer->rrs[i]);
+ if (r == 0) {
+ /* Hmm, if this is not an address record,
+ maybe it's a cname? If so, remember this */
+ r = dns_question_matches_cname(q->question, answer->rrs[i]);
+ if (r < 0)
+ goto parse_fail;
+ if (r > 0)
+ cname = dns_resource_record_ref(answer->rrs[i]);
- continue;
- }
+ continue;
+ }
- r = append_address(reply, answer->rrs[i], ifindex);
- if (r < 0)
- goto finish;
+ r = append_address(reply, answer->rrs[i], ifindex);
+ if (r < 0)
+ goto finish;
- if (!canonical)
- canonical = dns_resource_record_ref(answer->rrs[i]);
+ if (!canonical)
+ canonical = dns_resource_record_ref(answer->rrs[i]);
- added ++;
+ added ++;
+ }
}
if (added <= 0) {
@@ -347,20 +350,22 @@ static void bus_method_resolve_address_complete(DnsQuery *q) {
if (r < 0)
goto finish;
- answer = dns_answer_ref(q->answer);
+ if (q->answer) {
+ answer = dns_answer_ref(q->answer);
- for (i = 0; i < answer->n_rrs; i++) {
- r = dns_question_matches_rr(q->question, answer->rrs[i]);
- if (r < 0)
- goto parse_fail;
- if (r == 0)
- continue;
+ for (i = 0; i < answer->n_rrs; i++) {
+ r = dns_question_matches_rr(q->question, answer->rrs[i]);
+ if (r < 0)
+ goto parse_fail;
+ if (r == 0)
+ continue;
- r = sd_bus_message_append(reply, "s", answer->rrs[i]->ptr.name);
- if (r < 0)
- goto finish;
+ r = sd_bus_message_append(reply, "s", answer->rrs[i]->ptr.name);
+ if (r < 0)
+ goto finish;
- added ++;
+ added ++;
+ }
}
if (added <= 0) {