mirror of
https://github.com/samba-team/samba.git
synced 2024-12-25 23:21:54 +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:
parent
05c1e2db22
commit
b9d6ad85a8
@ -2829,6 +2829,7 @@ static int swrap_bind(int s, const struct sockaddr *myaddr, socklen_t addrlen)
|
|||||||
struct sockaddr_un un_addr;
|
struct sockaddr_un un_addr;
|
||||||
struct socket_info *si = find_socket_info(s);
|
struct socket_info *si = find_socket_info(s);
|
||||||
int bind_error = 0;
|
int bind_error = 0;
|
||||||
|
bool in_use;
|
||||||
|
|
||||||
if (!si) {
|
if (!si) {
|
||||||
return libc_bind(s, myaddr, addrlen);
|
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;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
in_use = check_addr_port_in_use(myaddr, addrlen);
|
||||||
|
if (in_use) {
|
||||||
|
errno = EADDRINUSE;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
free(si->myname);
|
free(si->myname);
|
||||||
si->myname_len = addrlen;
|
si->myname_len = addrlen;
|
||||||
si->myname = sockaddr_dup(myaddr, addrlen);
|
si->myname = sockaddr_dup(myaddr, addrlen);
|
||||||
|
Loading…
Reference in New Issue
Block a user