OSDN Git Service

do not use ghbn_buf after it goes out of scope
authorEric Andersen <andersen@codepoet.org>
Thu, 8 Feb 2007 21:02:26 +0000 (21:02 -0000)
committerEric Andersen <andersen@codepoet.org>
Thu, 8 Feb 2007 21:02:26 +0000 (21:02 -0000)
libc/inet/hostid.c

index 58dc13a..442294a 100644 (file)
@@ -72,19 +72,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