mirror of
https://git.FreeBSD.org/src.git
synced 2024-11-30 08:19:09 +00:00
- Return EAFNOSUPPORT instead of EINVAL for unsupported address family,
this matches the Linux behavior. - Check if we have sufficient space allocated for socket structure, which fixes a buffer overflow when wrong length is being passed into the emulation layer. [1] PR: kern/138860 Submitted by: Mateusz Guzik <mjguzik gmail com> Reported by: Alexander Best [1] MFC after: 2 weeks
This commit is contained in:
parent
61d033d436
commit
5cb9c68cc9
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=203728
@ -128,7 +128,7 @@ do_sa_get(struct sockaddr **sap, const struct osockaddr *osa, int *osalen,
|
||||
|
||||
bdom = linux_to_bsd_domain(kosa->sa_family);
|
||||
if (bdom == -1) {
|
||||
error = EINVAL;
|
||||
error = EAFNOSUPPORT;
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -157,8 +157,13 @@ do_sa_get(struct sockaddr **sap, const struct osockaddr *osa, int *osalen,
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
if (bdom == AF_INET)
|
||||
if (bdom == AF_INET) {
|
||||
alloclen = sizeof(struct sockaddr_in);
|
||||
if (*osalen < alloclen) {
|
||||
error = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
sa = (struct sockaddr *) kosa;
|
||||
sa->sa_family = bdom;
|
||||
|
Loading…
Reference in New Issue
Block a user