Open evverx opened 1 month ago
Hey @evverx ,
I also encountered that one, I did not yet do the PR, because I was trying to track what was the issue in on the ticket I created in avahi
repository.
About this issue, what I found out, is that it seems the A
record is always appended here, when creating an answer.
Right now, what I am testing is the following patch:
/* Copy the data bits only */
static void _a_copy(struct message *m, mdns_answer_t *a)
{
if (a->rdata) {
message_rdata_raw(m, a->rdata, a->rdlen);
return;
}
- if (a->type == QTYPE_A && a->ip.s_addr)
+ if (a->ip.s_addr)
message_rdata_ipv4(m, a->ip);
- else if (!IN6_IS_ADDR_UNSPECIFIED(&(a->ip6)))
+ else if (a->type == QTYPE_AAAA && && !IN6_IS_ADDR_UNSPECIFIED(&(a->ip6)))
message_rdata_ipv6(m, a->ip6);
if (a->type == QTYPE_SRV)
message_rdata_srv(m, a->srv.priority, a->srv.weight, a->srv.port, a->rdname);
else if (a->rdname)
message_rdata_name(m, a->rdname);
}
Right now, it seems to have fixed the issues you also encountered on your side. I am not yet done with the testing, therefore cannot say if this is a final fix. If you have some time and can test this, would help getting confidence here.
Best, Julián
@MonkeyBreaker I'm not familiar with the codebase but I applied the following patch (based on your diff with the second &&
removed)
diff --git a/libmdnsd/mdnsd.c b/libmdnsd/mdnsd.c
index 8f2d61a..4047a76 100644
--- a/libmdnsd/mdnsd.c
+++ b/libmdnsd/mdnsd.c
@@ -619,9 +619,9 @@ static void _a_copy(struct message *m, mdns_answer_t *a)
return;
}
- if (a->ip.s_addr)
+ if (a->type == QTYPE_A && a->ip.s_addr)
message_rdata_ipv4(m, a->ip);
- else if (!IN6_IS_ADDR_UNSPECIFIED(&(a->ip6)))
+ else if (a->type == QTYPE_AAAA && !IN6_IS_ADDR_UNSPECIFIED(&(a->ip6)))
message_rdata_ipv6(m, a->ip6);
if (a->type == QTYPE_SRV)
message_rdata_srv(m, a->srv.priority, a->srv.weight, a->srv.port, a->rdname);
and I can't see the malformed packets any more.
(Just to clarify I noticed it accidentally. I was just experimenting with mdnsd
to figure out if it can be integrated into the avahi testsuite since it allows sending things like those one-label CNAMEs that can cover code paths that aren't covered currently there. With mdnsd those test should be shorter than with, say, scapy).
I noticed log messages like
on various machines when I experimented with
mdnsd
in https://github.com/avahi/avahi/issues/614.mquery
showsBelow are the packets it sent and received:
The queries where the known answers were added are malformed:
It's reproducible with 5346604fcdeccd99f9943ac5ef887c3880480338.