mirror of
https://github.com/opnsense/src.git
synced 2026-06-10 01:00:30 -04:00
MAXHOSTNAMELEN includes space for the NUL
Don't read past the end of the host passed to realhostname() Not objected to by: freebsd-audit Interface disliked by: imp
This commit is contained in:
parent
3bd07cfd43
commit
ec86eec797
1 changed files with 4 additions and 4 deletions
|
|
@ -52,7 +52,7 @@ struct sockinet {
|
|||
int
|
||||
realhostname(char *host, size_t hsize, const struct in_addr *ip)
|
||||
{
|
||||
char trimmed[MAXHOSTNAMELEN+1];
|
||||
char trimmed[MAXHOSTNAMELEN];
|
||||
int result;
|
||||
struct hostent *hp;
|
||||
|
||||
|
|
@ -136,15 +136,15 @@ realhostname_sa(char *host, size_t hsize, struct sockaddr *addr, int addrlen)
|
|||
freeaddrinfo(ores);
|
||||
goto numeric;
|
||||
}
|
||||
strncpy(buf, ores->ai_canonname,
|
||||
strlcpy(buf, ores->ai_canonname,
|
||||
sizeof(buf));
|
||||
trimdomain(buf, hsize);
|
||||
strncpy(host, buf, hsize);
|
||||
if (strlen(host) > hsize &&
|
||||
if (strlen(buf) > hsize &&
|
||||
addr->sa_family == AF_INET) {
|
||||
freeaddrinfo(ores);
|
||||
goto numeric;
|
||||
}
|
||||
strncpy(host, buf, hsize);
|
||||
break;
|
||||
}
|
||||
((struct sockinet *)addr)->si_port = port;
|
||||
|
|
|
|||
Loading…
Reference in a new issue