[openbeosnetteam] Re: Fix for resolving host names

  • From: "Philippe Houdoin" <philippe.houdoin@xxxxxxx>
  • To: openbeosnetteam@xxxxxxxxxxxxx
  • Date: Tue, 03 Feb 2004 00:24:31 GMT

> Team,

Brennan,
:-)
 
> I fixed the issue with segmentation violations when resolving 
> hostnames 
> to IP addresses using /etc/hosts.  However, I don't really know if it 
> is a proper fix.  As you know, only the first line of /etc/hosts 
> would 
> work.  If the host name was on any line after 1, or was not in 
> /etc/hosts, or if /etc/hosts did not exist, you would get a 
> segmentation violation. 

So, shortly, when setting h_errno value, right ?

>  After much hunting around and dead ends, I 
> found that adding the following line to the gethostbyname(const char 
> *name) function in gethostnamadr.c as the first executable line of 
> code 
> seems to fix the issue:
> 
> h_errno = (int *)malloc(sizeof(int));
> 
> If you agree this is an actual fix, and not a workaround for a larger 
> problem that I'm not seeing, go ahead and submit it.

That's a workaround, as h_errno *should* works.
netdb.h define is as a macro:
#define h_errno (*(_h_errnop()))

Something is wrong about our h_errno TLS code, I guess.
Will look into it (src/kits/network/libnet/compat.c and headers/posix/
netdb.h)...

- Philippe


--
Fortune Cookie Says:

If today is the first day of the rest of your life, what the hell was
yesterday?

Other related posts: