From 84221b4e9010810cf93b7ad7a31d825fa9fc26bf Mon Sep 17 00:00:00 2001 From: Baptiste Assmann Date: Fri, 22 Jun 2018 13:03:50 +0200 Subject: [PATCH] MINOR: dns: fix wrong score computation in dns_get_ip_from_response dns_get_ip_from_response() is used to compare the caller current IP to the IP available in the records returned by the DNS server. A scoring system is in place to get the best IP address available. That said, in the current implementation, there are a couple of issues: 1. a comment does not match what the code does 2. the code does not match what the commet says (score value is not incremented with '2') This patch fixes both issues. Backport status: 1.8 --- src/dns.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/dns.c b/src/dns.c index c86e57d9c8..018c86a884 100644 --- a/src/dns.c +++ b/src/dns.c @@ -1024,10 +1024,13 @@ int dns_get_ip_from_response(struct dns_response_packet *dns_p, } /* Check if the IP found in the record is already affected to a - * member of a group. If yes, the score should be incremented + * member of a group. If not, the score should be incremented * by 2. */ - if (owner && snr_check_ip_callback(owner, ip, &ip_type)) + if (owner && snr_check_ip_callback(owner, ip, &ip_type)) { continue; + } else { + score += 2; + } /* Check for current ip matching. */ if (ip_type == currentip_sin_family &&