Cygwin: bindresvport: check correctness of address family
Assuming the address parameter is non-NULL, the test in cygwin_bindresvport_sa only tests if the address family is supported at all, which is insufficient. Check if the incoming address family matches the socket address family and for being AF_INET in cygwin_bindresvport since the latter doesn't support any other family. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
parent
34f031982f
commit
2f61f65601
@ -2482,6 +2482,11 @@ cygwin_bindresvport_sa (int fd, struct sockaddr *sa)
|
|||||||
memset (&sst, 0, sizeof sst);
|
memset (&sst, 0, sizeof sst);
|
||||||
sa->sa_family = fh->get_addr_family ();
|
sa->sa_family = fh->get_addr_family ();
|
||||||
}
|
}
|
||||||
|
else if (sa->sa_family != fh->get_addr_family ())
|
||||||
|
{
|
||||||
|
set_errno (EPFNOSUPPORT);
|
||||||
|
__leave;
|
||||||
|
}
|
||||||
|
|
||||||
switch (sa->sa_family)
|
switch (sa->sa_family)
|
||||||
{
|
{
|
||||||
@ -2529,10 +2534,14 @@ cygwin_bindresvport_sa (int fd, struct sockaddr *sa)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
extern "C" int
|
extern "C" int
|
||||||
cygwin_bindresvport (int fd, struct sockaddr_in *sin)
|
cygwin_bindresvport (int fd, struct sockaddr_in *sin)
|
||||||
{
|
{
|
||||||
|
if (sin && sin->sin_family != AF_INET)
|
||||||
|
{
|
||||||
|
set_errno (EAFNOSUPPORT);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
return cygwin_bindresvport_sa (fd, (struct sockaddr *) sin);
|
return cygwin_bindresvport_sa (fd, (struct sockaddr *) sin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user