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:

committed by
Nico Williams

parent
fa4c4430f6
commit
fd77c4000d
@@ -246,6 +246,11 @@ start_server(krb5_context contextp, const char *port_str)
|
||||
hints.ai_flags = AI_PASSIVE;
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
|
||||
if (krb5_config_get_bool(context, NULL, "libdefaults", "block_dns",
|
||||
NULL)) {
|
||||
hints.ai_flags &= ~AI_CANONNAME;
|
||||
hints.ai_flags |= AI_NUMERICHOST|AI_NUMERICSERV;
|
||||
}
|
||||
e = getaddrinfo(NULL, p->port, &hints, &ai);
|
||||
if(e) {
|
||||
snprintf(portstr, sizeof(portstr), "%u", p->def_port);
|
||||
|
Reference in New Issue
Block a user