port numbers should always be interpreted as decimal

per POSIX and RFC 3493:

If the specified address family is AF_INET, AF_INET6, or AF_UNSPEC,
the service can be specified as a string specifying a decimal port
number.

021 is a valid decimal number, therefore, interpreting it as octal
seems to be non-conformant.
This commit is contained in:
Rich Felker 2011-08-01 00:11:25 -04:00
parent e95b0a9d10
commit f4e8e64b82
1 changed files with 1 additions and 1 deletions

View File

@ -76,7 +76,7 @@ int getaddrinfo(const char *host, const char *serv, const struct addrinfo *hint,
if (serv) { if (serv) {
if (!*serv) return EAI_SERVICE; if (!*serv) return EAI_SERVICE;
port = strtoul(serv, &z, 0); port = strtoul(serv, &z, 10);
if (!*z && port > 65535) return EAI_SERVICE; if (!*z && port > 65535) return EAI_SERVICE;
if (!port) { if (!port) {
if (flags & AI_NUMERICSERV) return EAI_SERVICE; if (flags & AI_NUMERICSERV) return EAI_SERVICE;