aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Eric Andersen <andersen@codepoet.org>2007-02-08 21:01:06 +0000
committerGravatar Eric Andersen <andersen@codepoet.org>2007-02-08 21:01:06 +0000
commitcce8f18127302a7c770f8a2a09440b37ac36003a (patch)
treedcc909a9fbb77270ddafa1745337e6baacecf594
parentecc4874968e86f6c2074b5d7bf9150d0a56ae7ef (diff)
downloaduClibc-cce8f18127302a7c770f8a2a09440b37ac36003a.tar.gz
uClibc-cce8f18127302a7c770f8a2a09440b37ac36003a.tar.bz2
do not use ghbn_buf after it goes out of scope
-rw-r--r--libc/inet/hostid.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/libc/inet/hostid.c b/libc/inet/hostid.c
index efeedc93e..2f22dd146 100644
--- a/libc/inet/hostid.c
+++ b/libc/inet/hostid.c
@@ -55,19 +55,18 @@ long int gethostid(void)
if (gethostname(host,MAXHOSTNAMELEN)>=0 && *host) {
struct hostent *hp;
struct in_addr in;
+ 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;
/* 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);
- }
+ 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