summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2012-03-24 14:51:23 +0100
committerJelmer Vernooij <jelmer@samba.org>2012-03-24 14:51:23 +0100
commita9c22de3f44e00564dfb37fb4c7a99b485ffd96e (patch)
tree88889ef6bce4c529a8b2d97b606b89d54cd03a29 /source3
parenteb3617c426b8efc9021c94d2e1b9669eebbe1034 (diff)
downloadsamba-a9c22de3f44e00564dfb37fb4c7a99b485ffd96e.tar.gz
samba-a9c22de3f44e00564dfb37fb4c7a99b485ffd96e.tar.bz2
samba-a9c22de3f44e00564dfb37fb4c7a99b485ffd96e.zip
util_sock: Avoid sys_connect.
Diffstat (limited to 'source3')
-rw-r--r--source3/lib/util_sock.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c
index 69e33f7725..7fcb9c4c96 100644
--- a/source3/lib/util_sock.c
+++ b/source3/lib/util_sock.c
@@ -820,6 +820,7 @@ int open_udp_socket(const char *host, int port)
{
struct sockaddr_storage ss;
int res;
+ socklen_t salen;
if (!interpret_string_addr(&ss, host, 0)) {
DEBUG(10,("open_udp_socket: can't resolve name %s\n",
@@ -842,15 +843,20 @@ int open_udp_socket(const char *host, int port)
setup_linklocal_scope_id(
(struct sockaddr *)&ss);
}
- }
+ salen = sizeof(struct sockaddr_in6);
+ } else
#endif
- if (ss.ss_family == AF_INET) {
- struct sockaddr_in *psa;
- psa = (struct sockaddr_in *)&ss;
- psa->sin_port = htons(port);
- }
+ if (ss.ss_family == AF_INET) {
+ struct sockaddr_in *psa;
+ psa = (struct sockaddr_in *)&ss;
+ psa->sin_port = htons(port);
+ salen = sizeof(struct sockaddr_in);
+ } else {
+ DEBUG(1, ("unknown socket family %d", ss.ss_family));
+ return -1;
+ }
- if (sys_connect(res,(struct sockaddr *)&ss)) {
+ if (connect(res, (struct sockaddr *)&ss, salen)) {
close(res);
return -1;
}