Ensure all calls to getaddrinfo are headed by a block_dns check.

If block_dns is set, call getaddrinfo with AI_NUMERICHOST set and
AI_CANONNAME clear.

Some paths may not have set AI_CANONNAME, but it's easier to audit
this way when the getaddrinfo prelude is uniform across call sites,
and the compiler can optimize it away.
This commit is contained in:
Taylor R Campbell
2023-06-09 00:08:21 +00:00
committed by Nico Williams
parent fa4c4430f6
commit fd77c4000d
11 changed files with 70 additions and 4 deletions

View File

@@ -1210,6 +1210,11 @@ krb5_parse_address(krb5_context context,
/* if not parsed as numeric address, do a name lookup */
memset(&hint, 0, sizeof(hint));
hint.ai_family = AF_UNSPEC;
if (krb5_config_get_bool(context, NULL, "libdefaults", "block_dns",
NULL)) {
hint.ai_flags &= ~AI_CANONNAME;
hint.ai_flags |= AI_NUMERICHOST;
}
error = getaddrinfo (string, NULL, &hint, &ai);
if (error) {
krb5_error_code ret2;