From: Lennart Poettering Date: Mon, 24 Apr 2006 21:53:18 +0000 (+0000) Subject: add an extra validity check when parsing mDNS queries and records in packets X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=7e80cf6838c15be19cad03aeb80996d03a98921b;p=catta add an extra validity check when parsing mDNS queries and records in packets git-svn-id: file:///home/lennart/svn/public/avahi/trunk@1203 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe --- diff --git a/avahi-core/dns.c b/avahi-core/dns.c index 66b0bdf..c545c00 100644 --- a/avahi-core/dns.c +++ b/avahi-core/dns.c @@ -322,7 +322,6 @@ int avahi_dns_packet_check_valid_multicast(AvahiDnsPacket *p) { return 0; } - int avahi_dns_packet_is_query(AvahiDnsPacket *p) { assert(p); @@ -621,6 +620,9 @@ AvahiRecord* avahi_dns_packet_consume_record(AvahiDnsPacket *p, int *ret_cache_f if (parse_rdata(p, r, rdlength) < 0) goto fail; + + if (!avahi_record_is_valid(r)) + goto fail; return r; @@ -634,6 +636,7 @@ fail: AvahiKey* avahi_dns_packet_consume_key(AvahiDnsPacket *p, int *ret_unicast_response) { char name[256]; uint16_t type, class; + AvahiKey *k; assert(p); @@ -647,7 +650,15 @@ AvahiKey* avahi_dns_packet_consume_key(AvahiDnsPacket *p, int *ret_unicast_respo class &= ~AVAHI_DNS_UNICAST_RESPONSE; - return avahi_key_new(name, class, type); + if (!(k = avahi_key_new(name, class, type))) + return NULL; + + if (!avahi_key_is_valid(k)) { + avahi_key_unref(k); + return NULL; + } + + return k; } uint8_t* avahi_dns_packet_append_key(AvahiDnsPacket *p, AvahiKey *k, int unicast_response) {