NetBSD Problem Report #52376
From ef@math.uni-bonn.de Fri Jul 7 14:02:08 2017
Return-Path: <ef@math.uni-bonn.de>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id EC5D97A175
for <gnats-bugs@gnats.NetBSD.org>; Fri, 7 Jul 2017 14:02:08 +0000 (UTC)
Message-Id: <20170707140203.B55151BDE1@trave.math.uni-bonn.de>
Date: Fri, 7 Jul 2017 16:02:03 +0200 (CEST)
From: ef@math.uni-bonn.de
Reply-To: ef@math.uni-bonn.de
To: gnats-bugs@gnats.NetBSD.org
Subject: nss_{mdnsd,multicast_dns} broken
X-Send-Pr-Version: 3.95
>Number: 52376
>Category: lib
>Synopsis: nss_{mdnsd,multicast_dns} broken
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: lib-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri Jul 07 14:05:00 +0000 2017
>Closed-Date: Mon Jun 05 11:49:51 +0000 2023
>Last-Modified: Mon Jun 05 11:49:51 +0000 2023
>Originator: Edgar Fuß
>Release: NetBSD 6.1_STABLE
>Organization:
Mathematisches Institut der Universität Bonn
>Environment:
>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;
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback
State-Changed-By: riastradh@NetBSD.org
State-Changed-When: Sat, 27 May 2023 11:51:50 +0000
State-Changed-Why:
might be fixed, feedback requested
From: Edgar =?iso-8859-1?B?RnXf?= <ef@math.uni-bonn.de>
To: gnats-bugs@netbsd.org
Cc:
Subject: Re: lib/52376 (nss_{mdnsd,multicast_dns} broken)
Date: Mon, 5 Jun 2023 09:33:34 +0200
Yes, it seems to work on -8, too. The code is totally different from that in -6.
State-Changed-From-To: feedback->closed
State-Changed-By: riastradh@NetBSD.org
State-Changed-When: Mon, 05 Jun 2023 11:49:51 +0000
State-Changed-Why:
fixed with mdnsd update
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2023
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.