X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=avahi-compat-libdns_sd%2Fcompat.c;h=70ccd4b1ef3141b08508a6ad027851e01956fab4;hb=461b5328c99ef6af64f8d1313f63af8228ef720d;hp=afc92142dee3e9598ea5fa93f1c72d3a9cff649c;hpb=854f901f491ccda79aee11edc3d59109cb229d28;p=catta diff --git a/avahi-compat-libdns_sd/compat.c b/avahi-compat-libdns_sd/compat.c index afc9214..70ccd4b 100644 --- a/avahi-compat-libdns_sd/compat.c +++ b/avahi-compat-libdns_sd/compat.c @@ -33,6 +33,9 @@ #include #include +#include +#include + #include #include #include @@ -974,6 +977,7 @@ DNSServiceErrorType DNSSD_API DNSServiceRegister ( DNSServiceErrorType ret = kDNSServiceErr_Unknown; int error; DNSServiceRef sdref = NULL; + AvahiStringList *txt = NULL; AVAHI_WARN_LINKAGE; @@ -986,8 +990,14 @@ DNSServiceErrorType DNSSD_API DNSServiceRegister ( return kDNSServiceErr_Unsupported; } - if (!(sdref = sdref_new())) + if (txtRecord && txtLen > 0) + if (avahi_string_list_parse(txtRecord, txtLen, &txt) < 0) + return kDNSServiceErr_Invalid; + + if (!(sdref = sdref_new())) { + avahi_string_list_free(txt); return kDNSServiceErr_Unknown; + } sdref->context = context; sdref->service_register_callback = callback; @@ -998,7 +1008,7 @@ DNSServiceErrorType DNSSD_API DNSServiceRegister ( sdref->service_host = host ? avahi_normalize_name_strdup(host) : NULL; sdref->service_interface = interface == kDNSServiceInterfaceIndexAny ? AVAHI_IF_UNSPEC : (AvahiIfIndex) interface; sdref->service_port = ntohs(port); - sdref->service_txt = txtRecord && txtLen > 0 ? avahi_string_list_parse(txtRecord, txtLen) : NULL; + sdref->service_txt = txt; /* Some OOM checking would be cool here */