1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-24 21:34:56 +03:00

swrap: check whether an address:port is already in use in swrap_bind()

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
This commit is contained in:
Michael Adam 2014-06-03 15:14:44 +02:00
parent 05c1e2db22
commit b9d6ad85a8

View File

@ -2829,6 +2829,7 @@ static int swrap_bind(int s, const struct sockaddr *myaddr, socklen_t addrlen)
struct sockaddr_un un_addr;
struct socket_info *si = find_socket_info(s);
int bind_error = 0;
bool in_use;
if (!si) {
return libc_bind(s, myaddr, addrlen);
@ -2884,6 +2885,12 @@ static int swrap_bind(int s, const struct sockaddr *myaddr, socklen_t addrlen)
return -1;
}
in_use = check_addr_port_in_use(myaddr, addrlen);
if (in_use) {
errno = EADDRINUSE;
return -1;
}
free(si->myname);
si->myname_len = addrlen;
si->myname = sockaddr_dup(myaddr, addrlen);