From cc62c1a4aed3090bc75802327173a4ed66bcfc43 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Wed, 13 Apr 2016 18:39:45 -0500 Subject: [PATCH] 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 --- lib/krb5/krbhst.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/krb5/krbhst.c b/lib/krb5/krbhst.c index 5fb4b520b..2a93572cc 100644 --- a/lib/krb5/krbhst.c +++ b/lib/krb5/krbhst.c @@ -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);