summaryrefslogtreecommitdiffstats
path: root/usr.bin/rpcinfo
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>1998-06-09 04:31:02 +0000
committerimp <imp@FreeBSD.org>1998-06-09 04:31:02 +0000
commit8c96be00ef748f03f9e7f9f5934e7b0d53d1c872 (patch)
tree4cac82b29697cfe595adc937f0a97621ae134760 /usr.bin/rpcinfo
parent9a6732bd4e65d3bdaeb59e6b7cd0331484e1c331 (diff)
downloadFreeBSD-src-8c96be00ef748f03f9e7f9f5934e7b0d53d1c872.zip
FreeBSD-src-8c96be00ef748f03f9e7f9f5934e7b0d53d1c872.tar.gz
Don't assume that hp->h_lenght == 4. Be conservative in its use.
Submitted by: J. Assange a long time ago.
Diffstat (limited to 'usr.bin/rpcinfo')
-rw-r--r--usr.bin/rpcinfo/rpcinfo.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/usr.bin/rpcinfo/rpcinfo.c b/usr.bin/rpcinfo/rpcinfo.c
index d5161d0..f6cae71 100644
--- a/usr.bin/rpcinfo/rpcinfo.c
+++ b/usr.bin/rpcinfo/rpcinfo.c
@@ -2,7 +2,7 @@
/*static char sccsid[] = "from: @(#)rpcinfo.c 1.22 87/08/12 SMI";*/
/*static char sccsid[] = "from: @(#)rpcinfo.c 2.2 88/08/11 4.0 RPCSRC";*/
static char rcsid[] =
- "$Id: rpcinfo.c,v 1.5 1997/03/29 04:31:57 imp Exp $";
+ "$Id: rpcinfo.c,v 1.6 1997/08/06 06:49:06 charnier Exp $";
#endif
/*
@@ -52,6 +52,8 @@ static char rcsid[] =
#include <rpc/pmap_prot.h>
#include <rpc/pmap_clnt.h>
#include <signal.h>
+#include <ctype.h>
+#include <sys/param.h>
#define MAXHOSTLEN 256
@@ -496,7 +498,7 @@ pmapdump(argc, argv)
server_addr.sin_family = AF_INET;
if ((hp = gethostbyname("localhost")) != NULL)
bcopy(hp->h_addr, (caddr_t)&server_addr.sin_addr,
- hp->h_length);
+ MIN(hp->h_length,sizeof(server_addr.sin_addr)));
else
server_addr.sin_addr.s_addr = inet_addr("0.0.0.0");
}
@@ -653,8 +655,9 @@ get_inet_address(addr, host)
addr->sin_addr.s_addr = (u_long) inet_addr(host);
if (addr->sin_addr.s_addr == -1 || addr->sin_addr.s_addr == 0) {
if ((hp = gethostbyname(host)) == NULL)
- errx(1, "%s is unknown host", host);
- bcopy(hp->h_addr, (char *)&addr->sin_addr, hp->h_length);
+ errx(1, "%s is unknown host\n", host);
+ bcopy(hp->h_addr, (char *)&addr->sin_addr,
+ MIN(hp->h_length,sizeof(addr->sin_addr)));
}
addr->sin_family = AF_INET;
}
OpenPOWER on IntegriCloud