summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2010-10-30 16:07:31 +0200
committerStefan Metzmacher <metze@samba.org>2011-03-03 22:57:25 +0100
commite3c0d6611087184b37399df2bf04053c60c9f043 (patch)
tree76a21f1ea6919dda60c48a7d2003ecefbf08673f /lib
parent7b139a49dced08c4500960738bd0c06b5a57000e (diff)
downloadsamba-e3c0d6611087184b37399df2bf04053c60c9f043.tar.gz
samba-e3c0d6611087184b37399df2bf04053c60c9f043.tar.bz2
samba-e3c0d6611087184b37399df2bf04053c60c9f043.zip
socket_wrapper: don't allow connect() to the broadcast address
This will simplify other code later. metze
Diffstat (limited to 'lib')
-rw-r--r--lib/socket_wrapper/socket_wrapper.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/socket_wrapper/socket_wrapper.c b/lib/socket_wrapper/socket_wrapper.c
index 563c3a860d..346e0dfd45 100644
--- a/lib/socket_wrapper/socket_wrapper.c
+++ b/lib/socket_wrapper/socket_wrapper.c
@@ -1695,6 +1695,7 @@ _PUBLIC_ int swrap_connect(int s, const struct sockaddr *serv_addr, socklen_t ad
int ret;
struct sockaddr_un un_addr;
struct socket_info *si = find_socket_info(s);
+ int bcast = 0;
if (!si) {
return real_connect(s, serv_addr, addrlen);
@@ -1710,9 +1711,15 @@ _PUBLIC_ int swrap_connect(int s, const struct sockaddr *serv_addr, socklen_t ad
return -1;
}
- ret = sockaddr_convert_to_un(si, (const struct sockaddr *)serv_addr, addrlen, &un_addr, 0, NULL);
+ ret = sockaddr_convert_to_un(si, (const struct sockaddr *)serv_addr,
+ addrlen, &un_addr, 0, &bcast);
if (ret == -1) return -1;
+ if (bcast) {
+ errno = ENETUNREACH;
+ return -1;
+ }
+
if (si->type == SOCK_DGRAM) {
si->defer_connect = 1;
ret = 0;