resolved: handle more mDNS protocol details

This commit is contained in:
Daniel Mack 2015-09-03 12:09:11 +02:00
parent a20b959217
commit 547493c5ad

View file

@ -458,6 +458,13 @@ void dns_transaction_process_reply(DnsTransaction *t, DnsPacket *p) {
} }
if (DNS_PACKET_TC(p)) { if (DNS_PACKET_TC(p)) {
/* Truncated packets for mDNS are not allowed. Give up immediately. */
if (t->scope->protocol == DNS_PROTOCOL_MDNS) {
dns_transaction_complete(t, DNS_TRANSACTION_INVALID_REPLY);
return;
}
/* Response was truncated, let's try again with good old TCP */ /* Response was truncated, let's try again with good old TCP */
r = dns_transaction_open_tcp(t); r = dns_transaction_open_tcp(t);
if (r == -ESRCH) { if (r == -ESRCH) {
@ -466,7 +473,7 @@ void dns_transaction_process_reply(DnsTransaction *t, DnsPacket *p) {
return; return;
} }
if (r < 0) { if (r < 0) {
/* On LLMNR, if we cannot connect to the host, /* On LLMNR and mDNS, if we cannot connect to the host,
* we immediately give up */ * we immediately give up */
if (t->scope->protocol == DNS_PROTOCOL_LLMNR) { if (t->scope->protocol == DNS_PROTOCOL_LLMNR) {
dns_transaction_complete(t, DNS_TRANSACTION_RESOURCES); dns_transaction_complete(t, DNS_TRANSACTION_RESOURCES);
@ -493,6 +500,7 @@ void dns_transaction_process_reply(DnsTransaction *t, DnsPacket *p) {
return; return;
} }
if (t->scope->protocol == DNS_PROTOCOL_DNS) {
/* Only consider responses with equivalent query section to the request */ /* Only consider responses with equivalent query section to the request */
if (p->question->n_keys != 1 || dns_resource_key_equal(p->question->keys[0], t->key) <= 0) { if (p->question->n_keys != 1 || dns_resource_key_equal(p->question->keys[0], t->key) <= 0) {
dns_transaction_complete(t, DNS_TRANSACTION_INVALID_REPLY); dns_transaction_complete(t, DNS_TRANSACTION_INVALID_REPLY);
@ -516,6 +524,7 @@ void dns_transaction_process_reply(DnsTransaction *t, DnsPacket *p) {
0, 0,
p->family, p->family,
&p->sender); &p->sender);
}
if (DNS_PACKET_RCODE(p) == DNS_RCODE_SUCCESS) if (DNS_PACKET_RCODE(p) == DNS_RCODE_SUCCESS)
dns_transaction_complete(t, DNS_TRANSACTION_SUCCESS); dns_transaction_complete(t, DNS_TRANSACTION_SUCCESS);