summaryrefslogtreecommitdiffstats
path: root/lib/libc/rpc/getrpcport.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/rpc/getrpcport.c')
-rw-r--r--lib/libc/rpc/getrpcport.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/lib/libc/rpc/getrpcport.c b/lib/libc/rpc/getrpcport.c
index 24c6257f..193ef26 100644
--- a/lib/libc/rpc/getrpcport.c
+++ b/lib/libc/rpc/getrpcport.c
@@ -1,3 +1,5 @@
+/* $NetBSD: getrpcport.c,v 1.16 2000/01/22 22:19:18 mycroft Exp $ */
+
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* unrestricted use provided that this legend is included on all tape
@@ -27,9 +29,10 @@
* Mountain View, California 94043
*/
+#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)getrpcport.c 1.3 87/08/11 SMI";*/
-/*static char *sccsid = "from: @(#)getrpcport.c 2.1 88/07/29 4.0 RPCSRC";*/
+static char *sccsid = "@(#)getrpcport.c 1.3 87/08/11 SMI";
+static char *sccsid = "@(#)getrpcport.c 2.1 88/07/29 4.0 RPCSRC";
static char *rcsid = "$FreeBSD$";
#endif
@@ -37,12 +40,18 @@ static char *rcsid = "$FreeBSD$";
* Copyright (c) 1985 by Sun Microsystems, Inc.
*/
+#include "namespace.h"
+#include <sys/types.h>
+#include <sys/socket.h>
+
+#include <assert.h>
+#include <netdb.h>
#include <stdio.h>
#include <string.h>
+
#include <rpc/rpc.h>
#include <rpc/pmap_clnt.h>
-#include <netdb.h>
-#include <sys/socket.h>
+#include "un-namespace.h"
int
getrpcport(host, prognum, versnum, proto)
@@ -52,12 +61,18 @@ getrpcport(host, prognum, versnum, proto)
struct sockaddr_in addr;
struct hostent *hp;
+ assert(host != NULL);
+
if ((hp = gethostbyname(host)) == NULL)
return (0);
memset(&addr, 0, sizeof(addr));
addr.sin_len = sizeof(struct sockaddr_in);
addr.sin_family = AF_INET;
addr.sin_port = 0;
- memcpy((char *)&addr.sin_addr, hp->h_addr, hp->h_length);
- return (pmap_getport(&addr, prognum, versnum, proto));
+ if (hp->h_length > addr.sin_len)
+ hp->h_length = addr.sin_len;
+ memcpy(&addr.sin_addr.s_addr, hp->h_addr, (size_t)hp->h_length);
+ /* Inconsistent interfaces need casts! :-( */
+ return (pmap_getport(&addr, (u_long)prognum, (u_long)versnum,
+ (u_int)proto));
}
OpenPOWER on IntegriCloud