#include <netinet/in.h>
#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+
#include <avahi-common/simple-watch.h>
#include <avahi-common/malloc.h>
#include <avahi-common/error.h>
DNSServiceErrorType ret = kDNSServiceErr_Unknown;
int error;
DNSServiceRef sdref = NULL;
+ AvahiStringList *txt = NULL;
AVAHI_WARN_LINKAGE;
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;
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 */