From 0a2bbc528b7865b08139155e0316738a717c4e42 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 17 Nov 2004 00:05:25 +0000 Subject: * some commenting work * add new field "read_only" to memory blocks * add new API function pa_context_get_server() * filter capture data through mcalign on client * make module-tunnel use pa_socket_client_new_string() instead of using pa_resolve_server() directly. * remove pa_resolve_server() * remove debug.h and replace it by a macro definition on the gcc command line * some strbuf cleanups * small fixes in pa_stream for cleanup when server dies * new CLI command "load-sample-dir-lazy" * send FQDN as part of server info * rework mcalign, this time with memory block merging * fix iochannel cleanup when connection dies * check getaddrinfo() results git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@286 fefdeb5f-60dc-0310-8127-8f9354f1896f --- polyp/socket-client.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'polyp/socket-client.c') diff --git a/polyp/socket-client.c b/polyp/socket-client.c index b77d2aeb..aea38586 100644 --- a/polyp/socket-client.c +++ b/polyp/socket-client.c @@ -338,16 +338,24 @@ struct pa_socket_client* pa_socket_client_new_string(struct pa_mainloop_api *m, memset(&hints, 0, sizeof(hints)); hints.ai_family = kind == KIND_TCP4 ? AF_INET : (kind == KIND_TCP6 ? AF_INET6 : AF_UNSPEC); - if (getaddrinfo(h, NULL, &hints, &res) < 0 || !res) + if (getaddrinfo(h, NULL, &hints, &res) < 0 || !res || !res->ai_addr) return NULL; - if (res->ai_addr->sa_family == AF_INET) + if (res->ai_family == AF_INET) { + if (res->ai_addrlen != sizeof(struct sockaddr_in)) + return NULL; + assert(res->ai_addr->sa_family == res->ai_family); + ((struct sockaddr_in*) res->ai_addr)->sin_port = htons(port); - else if (res->ai_addr->sa_family == AF_INET6) + } else if (res->ai_family == AF_INET6) { + if (res->ai_addrlen != sizeof(struct sockaddr_in6)) + return NULL; + assert(res->ai_addr->sa_family == res->ai_family); + ((struct sockaddr_in6*) res->ai_addr)->sin6_port = htons(port); - else + } else return NULL; - + c = pa_socket_client_new_sockaddr(m, res->ai_addr, res->ai_addrlen); freeaddrinfo(res); return c; @@ -360,6 +368,9 @@ struct pa_socket_client* pa_socket_client_new_string(struct pa_mainloop_api *m, } +/* Return non-zero when the target sockaddr is considered + local. "local" means UNIX socket or TCP socket on localhost. Other + local IP addresses are not considered local. */ int pa_socket_client_is_local(struct pa_socket_client *c) { assert(c); return c->local; -- cgit