NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

lib/52376: nss_{mdnsd,multicast_dns} broken



>Number:         52376
>Category:       lib
>Synopsis:       nss_{mdnsd,multicast_dns} broken
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jul 07 14:05:00 +0000 2017
>Originator:     Edgar FuÃ?
>Release:        NetBSD 6.1_STABLE
>Organization:
	Mathematisches Institut der Universität Bonn
>Description:
	With mdnsd/multicast_dns as a nsswitch hosts source, gethostbyname() always returns localhost/127.0.0.1.
	The Problem is that gethostbyname_internal() passes, as fist argument to nsdispatch(), a pointer to a struct getnamaddr containing a pointer to the original struct hostent (passed to gethostbyname_r()); but _mdns_gethtbyname() then overwrites the pointer with the address of its own struct hostent (contained in its struct hostent_ctx). It should be copying the struct hostent instead. I hope I'm not confused.
	It looks like _mdns_gethtbyaddr() has the same problem. I haven't tested that.
	This is wth the old (NetBSD-6) nsswitch interface, I haven't looked into the new thread-safe one.
>How-To-Repeat:
	Setup mDNS, add multicast_dns as a hosts database in nsswitch.conf, call getent hosts xxx.local.
>Fix:
	Index: nss_mdnsd.c
	===================================================================
	RCS file: /cvsroot/src/external/apache2/mDNSResponder/nss/nss_mdnsd.c,v
	retrieving revision 1.3
	diff -u -p -r1.3 nss_mdnsd.c
	--- nss_mdnsd.c	4 Nov 2009 23:34:59 -0000	1.3
	+++ nss_mdnsd.c	7 Jul 2017 13:43:22 -0000
	@@ -454,7 +454,7 @@ _mdns_gethtbyaddr(void *cbrv, void *cbda
	     put_svc_ref(sr);
	 
	     if (h_ctx.naliases) {
	-        *(struct hostent **)cbrv = _mdns_hostent_done(&h_ctx);
	+        **(struct hostent **)cbrv = *_mdns_hostent_done(&h_ctx);
	     
		 return NS_SUCCESS;
	     } else {
	@@ -525,7 +525,7 @@ _mdns_gethtbyname(void *cbrv, void *cbda
	     if (err == NS_SUCCESS) {
		 _mdns_hostent_add_host(&h_ctx, sname);
		 _mdns_hostent_add_host(&h_ctx, name);
	-        *(struct hostent **)cbrv = _mdns_hostent_done(&h_ctx);
	+        **(struct hostent **)cbrv = *_mdns_hostent_done(&h_ctx);
	     }
	     
	     return err;



Home | Main Index | Thread Index | Old Index