Date: Mon, 5 Apr 2004 15:41:12 -0500 From: "Jacques A. Vidrine" <nectar@FreeBSD.org> To: Pierre Beyssac <pb@FreeBSD.org> Cc: audit@FreeBSD.org Subject: Re: fix for getipnodebyname(3) Message-ID: <20040405204112.GA17398@lum.celabo.org> In-Reply-To: <20040405173424.GA2440@bofh.enst.fr> References: <20040217161920.GB712@straylight.m.ringlet.net> <20040405173424.GA2440@bofh.enst.fr>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Apr 05, 2004 at 07:34:24PM +0200, Pierre Beyssac wrote: > getipnodebyname(3) as it stands in FreeBSD 4 and 5 has a problem > with nameserver timeouts or misconfiguration. > > Symptom: getipnodebyname(3) lookups in unreachable/unconfigured > zones return h_errno=HOST_NOT_FOUND instead of h_errno=TRY_AGAIN. > > It causes email to bounce at least with sendmail, which is quite > annoying. > > Unless someone objects to it, I'd like to commit the following fix > to current later today. Since FreeBSD 4 is impacted too, the patch > will have to be adapted and MFC'd some day. > > The only potential problem I see with my patch is that it accesses > h_errno, which is possibly not thread-safe. Could someone please > shed some light on this for me? > > Pierre > > --- name6.c.old Wed Feb 25 23:27:17 2004 > +++ name6.c Mon Apr 5 14:19:31 2004 > @@ -1565,7 +1565,8 @@ > continue; > hp = _hpcopy(&hpbuf, errp); > hp0 = _hpmerge(hp0, hp, errp); > - } > + } else > + *errp = h_errno; > } > if (hp0 != NULL) { > free(buf); > @@ -1604,7 +1605,8 @@ > continue; > hp = _hpcopy(&hpbuf, errp); > hp0 = _hpmerge(hp0, hp, errp); > - } > + } else > + *errp = h_errno; > } > if (hp0 != NULL) { > free(buf); > @@ -1677,7 +1679,8 @@ > continue; > hp = _hpcopy(&hpbuf, errp); > hp0 = _hpmerge(hp0, hp, errp); > - } > + } else > + *errp = h_errno; > } > if (hp0 != NULL) { > free(buf); > @@ -1739,7 +1742,12 @@ > rtl = &rtl4; > #endif > *(struct hostent **)rval = _res_search_multi(name, rtl, errp); > - return (*(struct hostent **)rval != NULL) ? NS_SUCCESS : NS_NOTFOUND; > + if (*(struct hostent **)rval != NULL) > + return NS_SUCCESS; > + else if (*errp == TRY_AGAIN) > + return NS_TRYAGAIN; > + else > + return NS_NOTFOUND; > } > > static int This fix looks correct to me. Hey, Pierre, one wonders why you bothered posting a patch for review if you were just going to commit it less than 3 hours later? Please allow more time next time. Good catch, BTW :-) Cheers, -- Jacques Vidrine / nectar@celabo.org / jvidrine@verio.net / nectar@freebsd.org
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040405204112.GA17398>