X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fnetwork%2Fgetaddrinfo.c;h=3d7b9ecd4e4b32775b38c4f84618ae12e2f20718;hb=2cc63358cdb0309ca996ffe56ccf402c2f2f16d5;hp=b9e562f7cdaae41287847d942cc18e59acd8269f;hpb=400c5e5c8307a2ebe44ef1f203f5a15669f20347;p=musl diff --git a/src/network/getaddrinfo.c b/src/network/getaddrinfo.c index b9e562f7..3d7b9ecd 100644 --- a/src/network/getaddrinfo.c +++ b/src/network/getaddrinfo.c @@ -76,8 +76,7 @@ int getaddrinfo(const char *restrict host, const char *restrict serv, const stru if (serv) { if (!*serv) return EAI_SERVICE; port = strtoul(serv, &z, 10); - if (!*z && port > 65535) return EAI_SERVICE; - if (!port) { + if (*z) { size_t servlen = strlen(serv); char *end = line; @@ -96,6 +95,7 @@ int getaddrinfo(const char *restrict host, const char *restrict serv, const stru __fclose_ca(f); if (feof(f)) return EAI_SERVICE; } + if (port > 65535) return EAI_SERVICE; port = htons(port); } @@ -219,7 +219,7 @@ int getaddrinfo(const char *restrict host, const char *restrict serv, const stru while (j--) buf[i++].sa.sin.sin_family = AF_INET6; } - if (__dns_get_rr((void *)&buf[cnt], 0, 256, 1, reply, RR_CNAME, 1) < 0) + if (__dns_get_rr((void *)&buf[cnt], 0, 256, 1, reply, RR_CNAME, 1) <= 0) strcpy((void *)&buf[cnt], host); for (i=0; i