diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-01-18 18:56:16 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-01-18 18:56:16 -0800 |
| commit | e6cded3832c9e92c922d49d824b446ce33fbf120 (patch) | |
| tree | f1ee4ab169c4e69c69699b2ce5c37bf368fc51e5 /src | |
| parent | 8049d822b3d8ea8bd11793369004c638d833964e (diff) | |
| download | nng-e6cded3832c9e92c922d49d824b446ce33fbf120.tar.gz nng-e6cded3832c9e92c922d49d824b446ce33fbf120.tar.bz2 nng-e6cded3832c9e92c922d49d824b446ce33fbf120.zip | |
Address segfault in TCP, and fix wild card handling.
Diffstat (limited to 'src')
| -rw-r--r-- | src/platform/posix/posix_net.c | 6 | ||||
| -rw-r--r-- | src/platform/windows/win_net.c | 4 | ||||
| -rw-r--r-- | src/transport/tcp/tcp.c | 3 |
3 files changed, 8 insertions, 5 deletions
diff --git a/src/platform/posix/posix_net.c b/src/platform/posix/posix_net.c index b89e7c49..eb85669f 100644 --- a/src/platform/posix/posix_net.c +++ b/src/platform/posix/posix_net.c @@ -46,7 +46,7 @@ nni_plat_to_sockaddr(struct sockaddr_storage *ss, const nni_sockaddr *sa) case NNG_AF_INET6: sin6 = (void *) ss; - memset(&sin6, 0, sizeof (sin6)); + memset(sin6, 0, sizeof (*sin6)); #ifdef SIN6_LEN sin6->sin6_len = sizeof (*sin6); #endif @@ -92,7 +92,7 @@ nni_plat_lookup_host(const char *host, nni_sockaddr *addr, int flags) struct addrinfo *ai; memset(&hint, 0, sizeof (hint)); - hint.ai_flags = AI_PASSIVE | AI_ADDRCONFIG; + hint.ai_flags = AI_PASSIVE | AI_ADDRCONFIG | AI_NUMERICSERV; hint.ai_family = PF_UNSPEC; hint.ai_socktype = SOCK_STREAM; hint.ai_protocol = IPPROTO_TCP; @@ -100,7 +100,7 @@ nni_plat_lookup_host(const char *host, nni_sockaddr *addr, int flags) hint.ai_family = PF_INET; } - if (getaddrinfo(host, NULL, &hint, &ai) != 0) { + if (getaddrinfo(host, "1", &hint, &ai) != 0) { return (NNG_EADDRINVAL); } diff --git a/src/platform/windows/win_net.c b/src/platform/windows/win_net.c index 36390053..bc237d0f 100644 --- a/src/platform/windows/win_net.c +++ b/src/platform/windows/win_net.c @@ -163,7 +163,7 @@ nni_plat_lookup_host(const char *host, nni_sockaddr *addr, int flags) ADDRINFO *ai; memset(&hint, 0, sizeof (hint)); - hint.ai_flags = AI_PASSIVE | AI_ADDRCONFIG; + hint.ai_flags = AI_PASSIVE | AI_ADDRCONFIG | AI_NUMERICSERV; hint.ai_family = PF_UNSPEC; hint.ai_socktype = SOCK_STREAM; hint.ai_protocol = IPPROTO_TCP; @@ -171,7 +171,7 @@ nni_plat_lookup_host(const char *host, nni_sockaddr *addr, int flags) hint.ai_family = PF_INET; } - if (getaddrinfo(host, NULL, &hint, &ai) != 0) { + if (getaddrinfo(host, "1", &hint, &ai) != 0) { return (NNG_EADDRINVAL); } diff --git a/src/transport/tcp/tcp.c b/src/transport/tcp/tcp.c index 09a2b385..d18fd289 100644 --- a/src/transport/tcp/tcp.c +++ b/src/transport/tcp/tcp.c @@ -343,6 +343,9 @@ nni_tcp_ep_connect(void *arg, void **pipep) if ((rv = nni_parseaddr(rempart, &host, &port)) != 0) { return (rv); } + if (host == NULL) { + return (NNG_EADDRINVAL); + } if ((rv = nni_plat_lookup_host(host, &remaddr, flag)) != 0) { return (rv); } |
