sunrpc: Always obtain AF_INET addresses from NSS [BZ #20964]
[platform/upstream/glibc.git] / sunrpc / clnt_simp.c
index d612df0..0ecb64c 100644 (file)
@@ -61,7 +61,6 @@ callrpc (const char *host, u_long prognum, u_long versnum, u_long procnum,
   struct callrpc_private_s *crp = callrpc_private;
   struct sockaddr_in server_addr;
   enum clnt_stat clnt_stat;
-  struct hostent hostbuf, *hp;
   struct timeval timeout, tottimeout;
 
   if (crp == 0)
@@ -84,10 +83,6 @@ callrpc (const char *host, u_long prognum, u_long versnum, u_long procnum,
     }
   else
     {
-      size_t buflen;
-      char *buffer;
-      int herr;
-
       crp->valid = 0;
       if (crp->socket != RPC_ANYSOCK)
        {
@@ -100,25 +95,11 @@ callrpc (const char *host, u_long prognum, u_long versnum, u_long procnum,
          crp->client = NULL;
        }
 
-      buflen = 1024;
-      buffer = __alloca (buflen);
-      while (__gethostbyname_r (host, &hostbuf, buffer, buflen,
-                               &hp, &herr) != 0
-            || hp == NULL)
-       if (herr != NETDB_INTERNAL || errno != ERANGE)
-         return (int) RPC_UNKNOWNHOST;
-       else
-         {
-           /* Enlarge the buffer.  */
-           buflen *= 2;
-           buffer = __alloca (buflen);
-         }
+      if (__libc_rpc_gethostbyname (host, &server_addr) != 0)
+       return (int) get_rpc_createerr().cf_stat;
 
       timeout.tv_usec = 0;
       timeout.tv_sec = 5;
-      memcpy ((char *) &server_addr.sin_addr, hp->h_addr, hp->h_length);
-      server_addr.sin_family = AF_INET;
-      server_addr.sin_port = 0;
       if ((crp->client = clntudp_create (&server_addr, (u_long) prognum,
                          (u_long) versnum, timeout, &crp->socket)) == NULL)
        return (int) get_rpc_createerr().cf_stat;