[avahi] [PATCH] improve libdns_sd compatibility
Trent Lloyd
lathiat at bur.st
Fri Mar 23 18:36:11 PDT 2007
Hi Chris,
Thanks for your patch, I don't have time to review this right this
second so I have opened a bug to ensure it is not forgotten:
http://www.avahi.org/ticket/118
Thanks for your contribution!
Cheers,
Trent
On Fri, Mar 23, 2007 at 03:48:17PM -0400, Chris Rivera wrote:
> Howdy folks.
>
> The attached patch replaces a few assertions with the returning of error
> codes in the libdns_sd compatibility layer. The last bit of the patch
> also fixes an invalid assertion on the txtRecord field of
> DNSServiceRegister(). From the comments above this function in dns_sd.h:
>
> "Passing NULL for the txtRecord is allowed as a synonym for txtLen=1,
> txtRecord="" ".
>
> The patch should apply cleanly to trunk.
>
> Thanks,
> Chris
> diff -ur /usr/src/packages/BUILD/avahi-0.6.17/avahi-compat-libdns_sd/compat.c ../avahi-compat-libdns_sd/compat.c
> --- avahi-compat-libdns_sd/compat.c 2007-01-06 13:29:05.000000000 -0500
> +++ avahi-compat-libdns_sd/compat.c 2007-03-07 16:32:59.000000000 -0500
> @@ -612,12 +612,10 @@
>
> AVAHI_WARN_LINKAGE;
>
> - if (!ret_sdref)
> + if (!ret_sdref || !regtype)
> return kDNSServiceErr_BadParam;
> *ret_sdref = NULL;
>
> - assert(regtype);
> -
> if (interface == kDNSServiceInterfaceIndexLocalOnly || flags != 0) {
> AVAHI_WARN_UNSUPPORTED;
> return kDNSServiceErr_Unsupported;
> @@ -739,15 +737,10 @@
>
> AVAHI_WARN_LINKAGE;
>
> - if (!ret_sdref)
> + if (!ret_sdref || !name || !regtype || !domain || !callback)
> return kDNSServiceErr_BadParam;
> *ret_sdref = NULL;
>
> - assert(name);
> - assert(regtype);
> - assert(domain);
> - assert(callback);
> -
> if (interface == kDNSServiceInterfaceIndexLocalOnly || flags != 0) {
> AVAHI_WARN_UNSUPPORTED;
> return kDNSServiceErr_Unsupported;
> @@ -795,9 +788,8 @@
>
> AVAHI_WARN_LINKAGE;
>
> - assert(fullName);
> - assert(regtype);
> - assert(domain);
> + if (!fullName || !regtype || !domain)
> + return -1;
>
> if (avahi_service_name_join(fullName, kDNSServiceMaxDomainName, service, regtype, domain) < 0)
> return -1;
> @@ -856,12 +848,10 @@
>
> AVAHI_WARN_LINKAGE;
>
> - if (!ret_sdref)
> + if (!ret_sdref || !callback)
> return kDNSServiceErr_BadParam;
> *ret_sdref = NULL;
>
> - assert(callback);
> -
> if (interface == kDNSServiceInterfaceIndexLocalOnly ||
> (flags != kDNSServiceFlagsBrowseDomains && flags != kDNSServiceFlagsRegistrationDomains)) {
> AVAHI_WARN_UNSUPPORTED;
> @@ -1100,14 +1090,14 @@
>
> AVAHI_WARN_LINKAGE;
>
> - if (!ret_sdref)
> + if (!ret_sdref || !regtype)
> return kDNSServiceErr_BadParam;
> *ret_sdref = NULL;
>
> - if (!regtype)
> - return kDNSServiceErr_BadParam;
> -
> - assert(txtRecord || txtLen == 0);
> + if (!txtRecord) {
> + txtLen = 1;
> + txtRecord = "";
> + }
>
> if (interface == kDNSServiceInterfaceIndexLocalOnly || flags) {
> AVAHI_WARN_UNSUPPORTED;
> _______________________________________________
> avahi mailing list
> avahi at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/avahi
More information about the avahi
mailing list