diff options
author | Michael Adam <obnox@samba.org> | 2014-06-03 15:14:44 +0200 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2014-06-05 23:57:10 +0200 |
commit | b9d6ad85a8711a86a7955e8c7ca17f0838b61008 (patch) | |
tree | 74f20402094f0899d4858764874fc9d922fb79c6 /lib/socket_wrapper/socket_wrapper.c | |
parent | 05c1e2db225be256da604d241da08ee0dc5ce0be (diff) | |
download | samba-b9d6ad85a8711a86a7955e8c7ca17f0838b61008.tar.gz |
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>
Diffstat (limited to 'lib/socket_wrapper/socket_wrapper.c')
-rw-r--r-- | lib/socket_wrapper/socket_wrapper.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/socket_wrapper/socket_wrapper.c b/lib/socket_wrapper/socket_wrapper.c index 477f1159715..f6adc95c152 100644 --- a/lib/socket_wrapper/socket_wrapper.c +++ b/lib/socket_wrapper/socket_wrapper.c @@ -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); |