mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-11-30 21:43:34 +00:00
Lose any stray host bits that a user may have entered when providing
a network number and netmask to the '-a' option. Approved by: ru MFC after: 1 week
This commit is contained in:
parent
e5a44502dd
commit
6ca048f825
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=79089
@ -1873,9 +1873,9 @@ allowaddr(s)
|
||||
if (res->ai_family == AF_INET) {
|
||||
ap.a_mask.ss_len = sizeof(struct sockaddr_in);
|
||||
maskp = &((struct sockaddr_in *)&ap.a_mask)->sin_addr;
|
||||
addrp = &((struct sockaddr_in *)&ap.a_addr)->sin_addr;
|
||||
if (masklen < 0) {
|
||||
/* use default netmask */
|
||||
addrp = &((struct sockaddr_in *)&ap.a_addr)->sin_addr;
|
||||
if (IN_CLASSA(ntohl(addrp->s_addr)))
|
||||
maskp->s_addr = htonl(IN_CLASSA_NET);
|
||||
else if (IN_CLASSB(ntohl(addrp->s_addr)))
|
||||
@ -1889,6 +1889,8 @@ allowaddr(s)
|
||||
freeaddrinfo(res);
|
||||
return -1;
|
||||
}
|
||||
/* Lose any host bits in the network number. */
|
||||
addrp->s_addr &= maskp->s_addr;
|
||||
}
|
||||
#ifdef INET6
|
||||
else if (res->ai_family == AF_INET6 && masklen <= 128) {
|
||||
|
Loading…
Reference in New Issue
Block a user