summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Voutila <voutilad@gmail.com>2021-01-02 17:44:13 -0500
committerGitHub <noreply@github.com>2021-01-02 14:44:13 -0800
commit6d5fcbbf4bac0639d531577786b158c24b60d9c6 (patch)
tree5a63b335d757b40a38dc23442c66055fefd73098
parent44b8e23f39e4753ba8e9b7999dd5158adaecb5dc (diff)
downloadnng-6d5fcbbf4bac0639d531577786b158c24b60d9c6.tar.gz
nng-6d5fcbbf4bac0639d531577786b158c24b60d9c6.tar.bz2
nng-6d5fcbbf4bac0639d531577786b158c24b60d9c6.zip
getaddrinfo(3) on musl & BSDs fails with servname = "" (#1396)
If one calls getaddrinfo(3) on OpenBSD like so, it returns -8 EAI_NONAME: struct addrinfo hints; struct addrinfo *results; int rv; results = NULL; memset(&hints, 0, sizeof(hints)); hints.ai_flags = AI_ADDRCONFIG; hints.ai_flags |= AI_PASSIVE; hints.ai_family = AF_INET; hints.ai_socktype = SOCK_STREAM; rv = getaddrinfo("localhost", "", &hints, &results); In the above code, that mirrors the current logic in resolv_task(), rv will end up being -8. On non-musl, non-BSD posix systems I tested (only amd64 Debian), it succeeds and returns 0.
-rw-r--r--src/platform/posix/posix_resolv_gai.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/platform/posix/posix_resolv_gai.c b/src/platform/posix/posix_resolv_gai.c
index 36a0924e..83974b3d 100644
--- a/src/platform/posix/posix_resolv_gai.c
+++ b/src/platform/posix/posix_resolv_gai.c
@@ -253,7 +253,7 @@ nni_resolv_ip(const char *host, const char *serv, int af, bool passive,
return;
}
- if (serv == NULL) {
+ if (serv == NULL || strcmp(serv, "") == 0) {
item->serv = NULL;
} else if ((item->serv = nni_strdup(serv)) == NULL) {
nni_aio_finish_error(aio, NNG_ENOMEM);