From owner-freebsd-audit@FreeBSD.ORG Mon Apr 5 13:41:51 2004 Return-Path: Delivered-To: freebsd-audit@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B536216A4CE; Mon, 5 Apr 2004 13:41:51 -0700 (PDT) Received: from gw.celabo.org (gw.celabo.org [208.42.49.153]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5BEDB43D1D; Mon, 5 Apr 2004 13:41:51 -0700 (PDT) (envelope-from nectar@celabo.org) Received: from localhost (localhost [127.0.0.1]) by gw.celabo.org (Postfix) with ESMTP id CA8815486E; Mon, 5 Apr 2004 15:41:50 -0500 (CDT) Received: from gw.celabo.org ([127.0.0.1]) by localhost (hellblazer.celabo.org [127.0.0.1]) (amavisd-new, port 10024) with SMTP id 73059-06; Mon, 5 Apr 2004 15:41:40 -0500 (CDT) Received: from lum.celabo.org (dhcp-207.celabo.org [10.0.1.207]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "lum.celabo.org", Issuer "celabo.org CA" (verified OK)) by gw.celabo.org (Postfix) with ESMTP id 21D1C54846; Mon, 5 Apr 2004 15:41:40 -0500 (CDT) Received: by lum.celabo.org (Postfix, from userid 501) id 4730B1B6580; Mon, 5 Apr 2004 15:41:12 -0500 (CDT) Date: Mon, 5 Apr 2004 15:41:12 -0500 From: "Jacques A. Vidrine" To: Pierre Beyssac Message-ID: <20040405204112.GA17398@lum.celabo.org> Mail-Followup-To: "Jacques A. Vidrine" , Pierre Beyssac , audit@FreeBSD.org, green@FreeBSD.org References: <20040217161920.GB712@straylight.m.ringlet.net> <20040405173424.GA2440@bofh.enst.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040405173424.GA2440@bofh.enst.fr> X-Url: http://www.celabo.org/ User-Agent: Mutt/1.5.6i cc: green@FreeBSD.org cc: audit@FreeBSD.org Subject: Re: fix for getipnodebyname(3) X-BeenThere: freebsd-audit@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: FreeBSD Security Audit List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Apr 2004 20:41:51 -0000 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