X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fnetwork%2Fgetaddrinfo.c;h=3d7b9ecd4e4b32775b38c4f84618ae12e2f20718;hb=158f721adc851850f22f789ad672deb6b88d511d;hp=838621668a7bfc241b7c2b1852211a07a6114dce;hpb=845a5e69fa33bf49eea81a7b8c80902ab1687f2e;p=musl diff --git a/src/network/getaddrinfo.c b/src/network/getaddrinfo.c index 83862166..3d7b9ecd 100644 --- a/src/network/getaddrinfo.c +++ b/src/network/getaddrinfo.c @@ -47,7 +47,7 @@ struct aibuf { /* Extra slots needed for storing canonical name */ #define EXTRA ((256+sizeof(struct aibuf)-1)/sizeof(struct aibuf)) -int getaddrinfo(const char *host, const char *serv, const struct addrinfo *hint, struct addrinfo **res) +int getaddrinfo(const char *restrict host, const char *restrict serv, const struct addrinfo *restrict hint, struct addrinfo **restrict res) { int flags = hint ? hint->ai_flags : 0; int family = hint ? hint->ai_family : AF_UNSPEC; @@ -76,8 +76,7 @@ int getaddrinfo(const char *host, const char *serv, const struct addrinfo *hint, 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 *host, const char *serv, const struct addrinfo *hint, __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 *host, const char *serv, const struct addrinfo *hint, 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