lib/krb5: fix srv_find_realm invalid gTLD test
In srv_find_realm() the conditional for testing whether an entry is the invalid gTLD response was inverted. Refactor the conditional into a helper function is_invalid_tld_srv_target(). Use the helper to simplify the conditional making it easier to confirm that the test is correct. Change-Id: I3220753b5585ac535862c4617030377c7a1f4bbe
This commit is contained in:
@@ -49,6 +49,14 @@ string_to_proto(const char *string)
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
is_invalid_tld_srv_target(const char *target)
|
||||
{
|
||||
return (strncmp("your-dns-needs-immediate-attention.",
|
||||
target, 35) == 0
|
||||
&& strchr(&target[35], '.') == NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* set `res' and `count' to the result of looking up SRV RR in DNS for
|
||||
* `proto', `proto', `realm' using `dns_type'.
|
||||
@@ -113,9 +121,7 @@ srv_find_realm(krb5_context context, krb5_krbhst_info ***res, int *count,
|
||||
int invalid_tld = 1;
|
||||
|
||||
/* Test for top-level domain controlled interruptions */
|
||||
if (strncmp("your-dns-needs-immediate-attention.",
|
||||
rr->u.srv->target, 35) == 0
|
||||
&& strchr(&rr->u.srv->target[35], '.') == NULL) {
|
||||
if (!is_invalid_tld_srv_target(rr->u.srv->target)) {
|
||||
invalid_tld = 0;
|
||||
len = strlen(rr->u.srv->target);
|
||||
hi = calloc(1, sizeof(*hi) + len);
|
||||
|
Reference in New Issue
Block a user