auditdns: Tidy up minor issues.
- Omit needless semicolon. - Reject obscene service numbers in getaddrinfo. - Fix mistake in comment about EAI_NONAME failure branch. Leftovers from: https://github.com/heimdal/heimdal/pull/1213
This commit is contained in:

committed by
Nico Williams

parent
e75e549252
commit
d73910c588
@@ -147,7 +147,7 @@ getaddrinfo(const char *hostname, const char *servname,
|
|||||||
break;
|
break;
|
||||||
case SOCK_DGRAM: /* datagram <-> UDP */
|
case SOCK_DGRAM: /* datagram <-> UDP */
|
||||||
if (hints->ai_protocol != 0 && hints->ai_protocol != IPPROTO_UDP) {
|
if (hints->ai_protocol != 0 && hints->ai_protocol != IPPROTO_UDP) {
|
||||||
error = EAI_SOCKTYPE;;
|
error = EAI_SOCKTYPE;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
socktype[0] = SOCK_DGRAM;
|
socktype[0] = SOCK_DGRAM;
|
||||||
@@ -178,9 +178,17 @@ getaddrinfo(const char *hostname, const char *servname,
|
|||||||
port = 0;
|
port = 0;
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* Service specified. Parse it as a nonnegative integer, at
|
* Service specified. First verify it is at most 5 decimal
|
||||||
* most 65535.
|
* digits; then parse it as a nonnegative integer in decimal,
|
||||||
|
* at most 65535. (This avoids pathological inputs like
|
||||||
|
* -18446744073709551493 for which strtoul will succeed and
|
||||||
|
* return 123 on LP64 platforms.)
|
||||||
*/
|
*/
|
||||||
|
if (strlen(servname) > strlen("65535") ||
|
||||||
|
strlen(servname) != strspn(servname, "0123456789")) {
|
||||||
|
error = EAI_NONAME;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
errno = 0;
|
errno = 0;
|
||||||
port = strtoul(servname, &servend, 10);
|
port = strtoul(servname, &servend, 10);
|
||||||
if (servend == servname ||
|
if (servend == servname ||
|
||||||
@@ -300,13 +308,13 @@ getaddrinfo(const char *hostname, const char *servname,
|
|||||||
goto have_addr;
|
goto have_addr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* No hostname, or hostname can't be parsed.
|
* Hostname can't be parsed.
|
||||||
*/
|
*/
|
||||||
error = EAI_NONAME;
|
error = EAI_NONAME;
|
||||||
goto out;
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
have_addr:
|
have_addr:
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user