Handle snrintf overflows.

Spotted by: bde
This commit is contained in:
Brian Somers 2001-08-20 13:44:13 +00:00
parent 36c1612b5e
commit 5f32890558
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=81978

View File

@ -746,6 +746,8 @@ _ftp_authenticate(int cd, struct url *url, struct url *purl)
logname = FTP_ANONYMOUS_USER;
if ((len = snprintf(pbuf, MAXLOGNAME + 1, "%s@", logname)) == -1)
len = 0;
else if (len > MAXLOGNAME)
len = MAXLOGNAME;
gethostname(pbuf + len, sizeof pbuf - len);
pwd = pbuf;
}