diff options
author | Lennart Poettering <lennart@poettering.net> | 2006-04-24 21:53:18 +0000 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2006-04-24 21:53:18 +0000 |
commit | 7e80cf6838c15be19cad03aeb80996d03a98921b (patch) | |
tree | cb23286e20e73b5caaae8cd121ebc8fe0b621605 /avahi-core | |
parent | ee2820a23c6968bbeadbdf510389301dca6bc765 (diff) |
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
Diffstat (limited to 'avahi-core')
-rw-r--r-- | avahi-core/dns.c | 15 |
1 files changed, 13 insertions, 2 deletions
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) { |