From owner-freebsd-audit@FreeBSD.ORG Mon Apr 5 10:34:27 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 C208916A4D3; Mon, 5 Apr 2004 10:34:27 -0700 (PDT) Received: from smtp2.enst.fr (reloaded.enst.fr [137.194.2.14]) by mx1.FreeBSD.org (Postfix) with ESMTP id D6CFE43D62; Mon, 5 Apr 2004 10:34:26 -0700 (PDT) (envelope-from beyssac@enst.fr) Received: from bofh.enst.fr (bofh.enst.fr [137.194.32.191]) (using TLSv1 with cipher EDH-RSA-DES-CBC3-SHA (168/168 bits)) (Client CN "bofh.enst.fr", Issuer "ENST CA" (verified OK)) by smtp2.enst.fr (Postfix) with ESMTP id 5EF5D21B; Mon, 5 Apr 2004 19:34:22 +0200 (CEST) Received: from enst.fr (localhost [127.0.0.1]) by bofh.enst.fr (8.12.11/8.12.11) with ESMTP id i35HYOAo003053 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 5 Apr 2004 19:34:25 +0200 (CEST) (envelope-from beyssac@enst.fr) Received: (from beyssac@localhost) by enst.fr (8.12.11/8.12.11/Submit) id i35HYOlk003052; Mon, 5 Apr 2004 19:34:24 +0200 (CEST) (envelope-from beyssac) Date: Mon, 5 Apr 2004 19:34:24 +0200 From: Pierre Beyssac To: audit@FreeBSD.org Message-ID: <20040405173424.GA2440@bofh.enst.fr> References: <20040217161920.GB712@straylight.m.ringlet.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040217161920.GB712@straylight.m.ringlet.net> User-Agent: Mutt/1.4.2.1i X-message-flag: Warning! Use of Microsoft Outlook makes your system susceptible to worms and viruses cc: green@FreeBSD.org Subject: 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 17:34:27 -0000 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 -- Pierre Beyssac pb@freebsd.org