summaryrefslogtreecommitdiff
path: root/libc/inet/hostid.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2007-02-02 01:29:10 +0000
committerEric Andersen <andersen@codepoet.org>2007-02-02 01:29:10 +0000
commit83b530eb6b7111486156fc5286a7f40742aeb2d0 (patch)
tree7aab0c2f107cbda453942a89f1a8eaed5a3ed48f /libc/inet/hostid.c
parentf21e442f635260e070527637c04574a4fe95fb4b (diff)
Ronald Maeder writes:
I have successfully made gethostbyname_r(), res_init(), and gethostid() fully reentrant. In addition, I have added a NULL check to inet_aton(). This is where SEG FAULTs were coming from when gethostbyname_r() was called.
Diffstat (limited to 'libc/inet/hostid.c')
-rw-r--r--libc/inet/hostid.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/libc/inet/hostid.c b/libc/inet/hostid.c
index 716bffaf3..58dc13aec 100644
--- a/libc/inet/hostid.c
+++ b/libc/inet/hostid.c
@@ -73,7 +73,19 @@ long int gethostid(void)
struct hostent *hp;
struct in_addr in;
- if ((hp = gethostbyname(host)) == (struct hostent *)NULL)
+ /* replace gethostbyname() with gethostbyname_r() - ron@zing.net */
+ /*if ((hp = gethostbyname(host)) == (struct hostent *)NULL)*/
+ {
+ struct hostent ghbn_h;
+ char ghbn_buf[sizeof(struct in_addr) +
+ sizeof(struct in_addr *)*2 +
+ sizeof(char *)*((2 + 5/*MAX_ALIASES*/ +
+ 1)/*ALIAS_DIM*/) +
+ 256/*namebuffer*/ + 32/* margin */];
+ int ghbn_errno;
+ gethostbyname_r(host, &ghbn_h, ghbn_buf, sizeof(ghbn_buf), &hp, &ghbn_errno);
+ }
+ if (hp == (struct hostent *)NULL)
/* This is not a error if we get here, as all it means is that
* this host is not on a network and/or they have not