From 6d96289942b0b55344f202cc2e941c45881e0c3a Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 9 Feb 2023 19:56:10 +0100 Subject: [PATCH] core: fix type for nameservers in nm_ip_config_dns_hash() nm_l3_config_data_get_nameservers() returns an array of in_addr_t or struct in6_addr. This is not a string list. Incidentally, it was still used correctly, using nm_ip_addr_from_packed_array(). Fix the code to use the right type. Also, only call g_checksum_update() once for the packed array. No need to iterate over the list one by one. Fixes: 8995d44a0bae ('core: compare the DNS configurations before updating DNS') --- src/core/nm-ip-config.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/nm-ip-config.c b/src/core/nm-ip-config.c index b191b54bb2..b61a932d9e 100644 --- a/src/core/nm-ip-config.c +++ b/src/core/nm-ip-config.c @@ -503,7 +503,7 @@ nm_ip_config_dns_hash(const NML3ConfigData *l3cd, GChecksum *sum, int addr_famil { guint i; int val; - const char *const *nameservers; + gconstpointer nameservers; const in_addr_t *wins; const char *const *domains; const char *const *searches; @@ -518,10 +518,10 @@ nm_ip_config_dns_hash(const NML3ConfigData *l3cd, GChecksum *sum, int addr_famil g_return_if_fail(sum); nameservers = nm_l3_config_data_get_nameservers(l3cd, addr_family, &num_nameservers); - for (i = 0; i < num_nameservers; i++) { + if (num_nameservers > 0) { g_checksum_update(sum, - nm_ip_addr_from_packed_array(addr_family, nameservers, i), - nm_utils_addr_family_to_size(addr_family)); + nameservers, + num_nameservers * nm_utils_addr_family_to_size(addr_family)); } if (addr_family == AF_INET) {