The source strings are from the password database which guarantees

that the data going into it is sane.  Out of an abundance of caution,
limit the string copies to prevent an overflow.

CID: 1019035
This commit is contained in:
Warner Losh 2018-01-06 12:46:04 +00:00
parent ca23e64eb4
commit 90ceddb160

View File

@ -457,8 +457,8 @@ iruserok_sa(const void *ra, int rlen, int superuser, const char *ruser,
first = 0;
if ((pwd = getpwnam(luser)) == NULL)
return (-1);
(void)strcpy(pbuf, pwd->pw_dir);
(void)strcat(pbuf, "/.rhosts");
(void)strlcpy(pbuf, pwd->pw_dir, sizeof(pbuf));
(void)strlcat(pbuf, "/.rhosts", sizeof(pbuf));
/*
* Change effective uid while opening .rhosts. If root and