about summary refs log tree commit diff
path: root/inet
diff options
context:
space:
mode:
Diffstat (limited to 'inet')
-rw-r--r--inet/rcmd.c9
-rw-r--r--inet/rexec.c4
-rw-r--r--inet/ruserpass.c11
3 files changed, 17 insertions, 7 deletions
diff --git a/inet/rcmd.c b/inet/rcmd.c
index 1c63e952dc..a9756d109a 100644
--- a/inet/rcmd.c
+++ b/inet/rcmd.c
@@ -52,6 +52,9 @@ static char sccsid[] = "@(#)rcmd.c	8.3 (Berkeley) 3/26/94";
 #include <ctype.h>
 #include <string.h>
 
+#define MIN(A, B) ((A) < (B) ? (A) : (B))
+
+
 int	__ivaliduser __P((FILE *, u_int32_t, const char *, const char *));
 static int __icheckhost __P((u_int32_t, char *));
 
@@ -92,7 +95,8 @@ rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
 		}
 		fcntl(s, F_SETOWN, pid);
 		sin.sin_family = hp->h_addrtype;
-		bcopy(hp->h_addr_list[0], &sin.sin_addr, hp->h_length);
+		bcopy(hp->h_addr_list[0], &sin.sin_addr,
+		      MIN (sizeof (sin.sin_addr), hp->h_length));
 		sin.sin_port = rport;
 		if (connect(s, (struct sockaddr *)&sin, sizeof(sin)) >= 0)
 			break;
@@ -114,7 +118,8 @@ rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
 			__set_errno (oerrno);
 			perror(0);
 			hp->h_addr_list++;
-			bcopy(hp->h_addr_list[0], &sin.sin_addr, hp->h_length);
+			bcopy(hp->h_addr_list[0], &sin.sin_addr,
+			      MIN (sizeof (sin.sin_addr), hp->h_length));
 			(void)fprintf(stderr, _("Trying %s...\n"),
 			    inet_ntoa(sin.sin_addr));
 			continue;
diff --git a/inet/rexec.c b/inet/rexec.c
index 297e44402d..7533410eb3 100644
--- a/inet/rexec.c
+++ b/inet/rexec.c
@@ -91,9 +91,9 @@ retry:
 		(void) write(s, "", 1);
 		port = 0;
 	} else {
-		char num[8];
+		char num[32];
 		int s2, sin2len;
-		
+
 		s2 = socket(AF_INET, SOCK_STREAM, 0);
 		if (s2 < 0) {
 			(void) close(s);
diff --git a/inet/ruserpass.c b/inet/ruserpass.c
index cff9493b07..a0a4b97bdb 100644
--- a/inet/ruserpass.c
+++ b/inet/ruserpass.c
@@ -87,9 +87,14 @@ ruserpass(host, aname, apass)
 	int t, i, c, usedefault = 0;
 	struct stat stb;
 
-	hdir = getenv("HOME");
-	if (hdir == NULL)
-		hdir = ".";
+	hdir = __secure_getenv("HOME");
+	if (hdir == NULL) {
+		/* If we can't get HOME, fail instead of trying ".",
+		   which is no improvement. This really should call
+		   getpwuid(getuid()).  */
+		/*hdir = ".";*/
+	  	return -1;
+	}
 
 	buf = alloca (strlen (hdir) + 8);