diff options
author | Lorenzo Colitti <lorenzo@google.com> | 2014-09-09 10:22:17 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2014-09-09 10:22:18 +0000 |
commit | c71483c0b38a6b4f2675f0bffa221dcf175c34ac (patch) | |
tree | c96beb6409da536ba658b019081fe765278e3186 /libc/dns | |
parent | 3c3624f3df14590e7213d35c3b39a0a11c7d2d34 (diff) | |
parent | bce18c91638e9f37ef2c37555cbb41a0f1f98ab0 (diff) | |
download | bionic-c71483c0b38a6b4f2675f0bffa221dcf175c34ac.zip bionic-c71483c0b38a6b4f2675f0bffa221dcf175c34ac.tar.gz bionic-c71483c0b38a6b4f2675f0bffa221dcf175c34ac.tar.bz2 |
Merge "When comparing DNS server configs, also compare number of servers"
Diffstat (limited to 'libc/dns')
-rw-r--r-- | libc/dns/resolv/res_cache.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/libc/dns/resolv/res_cache.c b/libc/dns/resolv/res_cache.c index 0201aa8..9ca5419 100644 --- a/libc/dns/resolv/res_cache.c +++ b/libc/dns/resolv/res_cache.c @@ -1965,10 +1965,25 @@ _resolv_is_nameservers_equal_locked(struct resolv_cache_info* cache_info, { int i; char** ns; + int currentservers; int equal = 1; - // compare each name server against current name servers if (numservers > MAXNS) numservers = MAXNS; + + // Find out how many nameservers we had before. + currentservers = 0; + for (ns = cache_info->nameservers; *ns; ns++) + currentservers++; + + if (currentservers != numservers) + return 0; + + // Compare each name server against current name servers. + // TODO: this is incorrect if the list of current or previous nameservers + // contains duplicates. This does not really matter because the framework + // filters out duplicates, but we should probably fix it. It's also + // insensitive to the order of the nameservers; we should probably fix that + // too. for (i = 0; i < numservers && equal; i++) { ns = cache_info->nameservers; equal = 0; |