From 8c96be00ef748f03f9e7f9f5934e7b0d53d1c872 Mon Sep 17 00:00:00 2001 From: imp Date: Tue, 9 Jun 1998 04:31:02 +0000 Subject: Don't assume that hp->h_lenght == 4. Be conservative in its use. Submitted by: J. Assange a long time ago. --- usr.bin/rpcinfo/rpcinfo.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'usr.bin/rpcinfo/rpcinfo.c') 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 #include #include +#include +#include #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; } -- cgit v1.1