]> git.meshlink.io Git - catta/commitdiff
add an extra validity check when parsing mDNS queries and records in packets
authorLennart Poettering <lennart@poettering.net>
Mon, 24 Apr 2006 21:53:18 +0000 (21:53 +0000)
committerLennart Poettering <lennart@poettering.net>
Mon, 24 Apr 2006 21:53:18 +0000 (21:53 +0000)
git-svn-id: file:///home/lennart/svn/public/avahi/trunk@1203 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe

avahi-core/dns.c

index 66b0bdf8c01e1bfdd57c74823181855bb9af9e7e..c545c00ea33c19f4301974a3debc7b32d52a9bac 100644 (file)
@@ -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) {