summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAvi2025-03-11 02:18:19 +0000
committerFelix Fietkau2025-05-28 22:28:57 +0000
commitcecbe1c0caaee3de70bea0413b9f90d4b5b5ca36 (patch)
tree26d698b648c2293158f0f0232b57ba9df55111a4
parent695ac3708aa014aee9be77f91da2699eef1b4c66 (diff)
downloadmdnsd-cecbe1c0caaee3de70bea0413b9f90d4b5b5ca36.tar.gz
Make mdns responder case-insensitive.
From [the RFC](https://github.com/openwrt/mdnsd/blob/master/rfc6762.txt#L2532-L2550): > The simple rules for case-insensitivity in Unicast DNS [RFC1034] [RFC1035] also apply in Multicast DNS; that is to say, in name comparisons, the lowercase letters "a" to "z" (0x61 to 0x7A) match their uppercase equivalents "A" to "Z" (0x41 to 0x5A). Hence, if a querier issues a query for an address record with the name "myprinter.local.", then a responder having an address record with the name "MyPrinter.local." should issue a response. No other automatic equivalences should be assumed. Fixes #15. Signed-off-by: Felix Fietkau <nbd@nbd.name>
-rw-r--r--dns.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/dns.c b/dns.c
index 18210f1..a20fb3e 100644
--- a/dns.c
+++ b/dns.c
@@ -11,6 +11,7 @@
* GNU General Public License for more details.
*/
+#define _GNU_SOURCE
#include <sys/types.h>
#include <sys/stat.h>
@@ -458,7 +459,7 @@ parse_question(struct interface *iface, struct sockaddr *from, char *name, struc
switch (q->type) {
case TYPE_ANY:
- if (!strcmp(name, mdns_hostname_local)) {
+ if (!strcasecmp(name, mdns_hostname_local)) {
dns_reply_a(iface, to, announce_ttl, NULL);
dns_reply_a_additional(iface, to, announce_ttl);
service_reply(iface, to, NULL, NULL, announce_ttl, is_unicast);
@@ -466,7 +467,7 @@ parse_question(struct interface *iface, struct sockaddr *from, char *name, struc
break;
case TYPE_PTR:
- if (!strcmp(name, C_DNS_SD)) {
+ if (!strcasecmp(name, C_DNS_SD)) {
service_announce_services(iface, to, announce_ttl);
} else {
if (name[0] == '_') {
@@ -486,16 +487,16 @@ parse_question(struct interface *iface, struct sockaddr *from, char *name, struc
case TYPE_AAAA:
case TYPE_A:
- host = strstr(name, ".local");
+ host = strcasestr(name, ".local");
if (host)
*host = '\0';
- if (!strcmp(umdns_host_label, name)) {
+ if (!strcasecmp(umdns_host_label, name)) {
dns_reply_a(iface, to, announce_ttl, NULL);
} else {
if (host)
*host = '.';
vlist_for_each_element(&hostnames, h, node)
- if (!strcmp(h->hostname, name))
+ if (!strcasecmp(h->hostname, name))
dns_reply_a(iface, to, announce_ttl, h->hostname);
}
break;