fix for getipnodebyname(3)
Jacques A. Vidrine
nectar at FreeBSD.org
Mon Apr 5 13:41:51 PDT 2004
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 at celabo.org / jvidrine at verio.net / nectar at freebsd.org
More information about the freebsd-audit
mailing list