1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-17 15:27:36 +00:00

Fix PR2579: potential security hole in rcmd.c

Submitted by:	Julian Assange
This commit is contained in:
Warner Losh 1997-02-09 06:54:46 +00:00
parent ad1b44de84
commit 5480d8d5c2
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=22469

View File

@ -104,7 +104,7 @@ rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
sin.sin_len = sizeof(struct sockaddr_in);
sin.sin_family = hp->h_addrtype;
sin.sin_port = rport;
bcopy(hp->h_addr_list[0], &sin.sin_addr, hp->h_length);
bcopy(hp->h_addr_list[0], &sin.sin_addr, MIN(hp->h_length, sizeof sin.sin_addr));
if (connect(s, (struct sockaddr *)&sin, sizeof(sin)) >= 0)
break;
(void)close(s);
@ -125,7 +125,7 @@ rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
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(hp->h_length, sizeof sin.sin_addr));
(void)fprintf(stderr, "Trying %s...\n",
inet_ntoa(sin.sin_addr));
continue;