.
[kopensolaris-gnu/glibc.git] / nss / digits_dots.c
index b86f66c..944b328 100644 (file)
@@ -25,7 +25,6 @@
     {
       const char *cp;
       char *hostname;
     {
       const char *cp;
       char *hostname;
-      struct hostent *host;
       typedef unsigned char host_addr_t [16];
       host_addr_t *host_addr;
       typedef char *host_addr_list_t [2];
       typedef unsigned char host_addr_t [16];
       host_addr_t *host_addr;
       typedef char *host_addr_list_t [2];
 
        default:
          af = (_res.options & RES_USE_INET6) ? AF_INET6 : AF_INET;
 
        default:
          af = (_res.options & RES_USE_INET6) ? AF_INET6 : AF_INET;
-         addr_size = (af == AF_INET6 ) ? IN6ADDRSZ : INADDRSZ;
+         addr_size = af == AF_INET6 ? IN6ADDRSZ : INADDRSZ;
          break;
        }
 
          break;
        }
 
-      size_needed = (sizeof (*host) + sizeof (*host_addr)
+      size_needed = (sizeof (*host_addr)
                     + sizeof (*host_aliases) + sizeof (*h_addr_ptrs)
                     + strlen (name) + 1);
 
                     + sizeof (*host_aliases) + sizeof (*h_addr_ptrs)
                     + strlen (name) + 1);
 
@@ -86,8 +85,7 @@
 
       memset (buffer, 0, size_needed);
 
 
       memset (buffer, 0, size_needed);
 
-      host = (struct hostent *) buffer;
-      host_addr = (host_addr_t *) ((char *) host + sizeof (*host));
+      host_addr = (host_addr_t *) buffer;
       host_aliases = (host_addr_list_t *)
        ((char *) host_addr + sizeof (*host_addr));
       h_addr_ptrs = (host_addr_list_t *)
       host_aliases = (host_addr_list_t *)
        ((char *) host_addr + sizeof (*host_addr));
       h_addr_ptrs = (host_addr_list_t *)
                      goto done;
                    }
 
                      goto done;
                    }
 
-                 strcpy (hostname, name);
-                 host->h_name = hostname;
-                 host->h_aliases = *host_aliases;
+                 resbuf.h_name = strcpy (hostname, name);
+                 resbuf.h_aliases = *host_aliases;
                  (*host_aliases)[0] = NULL;
                  (*h_addr_ptrs)[0] = (char *)host_addr;
                  (*h_addr_ptrs)[1] = (char *)0;
                  (*host_aliases)[0] = NULL;
                  (*h_addr_ptrs)[0] = (char *)host_addr;
                  (*h_addr_ptrs)[1] = (char *)0;
-                 host->h_addr_list = *h_addr_ptrs;
+                 resbuf.h_addr_list = *h_addr_ptrs;
                  if (_res.options & RES_USE_INET6 && af == AF_INET)
                    {
                      /* We need to change the IP v4 address into the
                  if (_res.options & RES_USE_INET6 && af == AF_INET)
                    {
                      /* We need to change the IP v4 address into the
                      *p++ = 0xff;
                      /* Copy the IP v4 address. */
                      memcpy (p, tmp, INADDRSZ);
                      *p++ = 0xff;
                      /* Copy the IP v4 address. */
                      memcpy (p, tmp, INADDRSZ);
-                     host->h_addrtype = AF_INET6;
-                     host->h_length = IN6ADDRSZ;
+                     resbuf.h_addrtype = AF_INET6;
+                     resbuf.h_length = IN6ADDRSZ;
                    }
                  else
                    {
                    }
                  else
                    {
-                     host->h_addrtype = af;
-                     host->h_length = addr_size;
+                     resbuf.h_addrtype = af;
+                     resbuf.h_length = addr_size;
                    }
                  __set_h_errno (NETDB_SUCCESS);
 #ifdef HAVE_LOOKUP_BUFFER
                  status = NSS_STATUS_SUCCESS;
 #else
                    }
                  __set_h_errno (NETDB_SUCCESS);
 #ifdef HAVE_LOOKUP_BUFFER
                  status = NSS_STATUS_SUCCESS;
 #else
-                 result = host;
+                 result = &resbuf;
 #endif
                  goto done;
                }
 #endif
                  goto done;
                }
            }
        }
 
            }
        }
 
-      if (isxdigit (name[0]) || name[0] == ':')
+      if ((isxdigit (name[0]) && strchr (name, ':') != NULL)
+         || name[0] == ':')
        {
          const char *cp;
          char *hostname;
        {
          const char *cp;
          char *hostname;
-         struct hostent *host;
          typedef unsigned char host_addr_t [16];
          host_addr_t *host_addr;
          typedef char *host_addr_list_t [2];
          typedef unsigned char host_addr_t [16];
          host_addr_t *host_addr;
          typedef char *host_addr_list_t [2];
              break;
            }
 
              break;
            }
 
-         size_needed = (sizeof (*host) + sizeof (*host_addr)
+         size_needed = (sizeof (*host_addr)
                         + sizeof (*host_aliases) + sizeof (*h_addr_ptrs)
                         + strlen (name) + 1);
 
                         + sizeof (*host_aliases) + sizeof (*h_addr_ptrs)
                         + strlen (name) + 1);
 
 
          memset (buffer, 0, size_needed);
 
 
          memset (buffer, 0, size_needed);
 
-         host = (struct hostent *) buffer;
-         host_addr = (host_addr_t *) ((char *) host + sizeof (*host));
+         host_addr = (host_addr_t *) buffer;
          host_aliases = (host_addr_list_t *)
            ((char *) host_addr + sizeof (*host_addr));
          h_addr_ptrs = (host_addr_list_t *)
          host_aliases = (host_addr_list_t *)
            ((char *) host_addr + sizeof (*host_addr));
          h_addr_ptrs = (host_addr_list_t *)
            {
              if (!*cp)
                {
            {
              if (!*cp)
                {
-                 if (*--cp == '.') break;
+                 if (*--cp == '.')
+                   break;
 
                  /* All-IPv6-legal, no dot at the end. Fake up a
                     hostent as if we'd actually done a lookup.  */
 
                  /* All-IPv6-legal, no dot at the end. Fake up a
                     hostent as if we'd actually done a lookup.  */
                      goto done;
                    }
 
                      goto done;
                    }
 
-                 strcpy (hostname, name);
-                 host->h_name = hostname;
-                 host->h_aliases = *host_aliases;
+                 resbuf.h_name = strcpy (hostname, name);
+                 resbuf.h_aliases = *host_aliases;
                  (*host_aliases)[0] = NULL;
                  (*h_addr_ptrs)[0] = (char *) host_addr;
                  (*h_addr_ptrs)[1] = (char *) 0;
                  (*host_aliases)[0] = NULL;
                  (*h_addr_ptrs)[0] = (char *) host_addr;
                  (*h_addr_ptrs)[1] = (char *) 0;
-                 host->h_addr_list = *h_addr_ptrs;
-                 host->h_addrtype = af;
-                 host->h_length = addr_size;
+                 resbuf.h_addr_list = *h_addr_ptrs;
+                 resbuf.h_addrtype = af;
+                 resbuf.h_length = addr_size;
                  __set_h_errno (NETDB_SUCCESS);
 #ifdef HAVE_LOOKUP_BUFFER
                  status = NSS_STATUS_SUCCESS;
 #else
                  __set_h_errno (NETDB_SUCCESS);
 #ifdef HAVE_LOOKUP_BUFFER
                  status = NSS_STATUS_SUCCESS;
 #else
-                 result = host;
+                 result = &resbuf;
 #endif
                  goto done;
                }
 #endif
                  goto done;
                }