dns: assert early that @iface is not NULL

Under no circumstance should a non-global configuration with NULL or
empty iface be added to the DNS manager. Assert this early and remove
other unnecessary checks.

(cherry picked from commit 027f4c65ac)
This commit is contained in:
Beniamino Galvani 2016-05-11 18:21:36 +02:00 committed by Thomas Haller
parent 46ab13eda1
commit c42f455251
2 changed files with 4 additions and 3 deletions

View file

@ -163,7 +163,7 @@ ip6_addr_to_string (const struct in6_addr *addr, const char *iface)
if (IN6_IS_ADDR_V4MAPPED (addr)) {
buf = g_malloc (INET_ADDRSTRLEN);
nm_utils_inet4_ntop (addr->s6_addr32[3], buf);
} else if (!iface || !iface[0] || !IN6_IS_ADDR_LINKLOCAL (addr)) {
} else if (!IN6_IS_ADDR_LINKLOCAL (addr)) {
buf = g_malloc (INET6_ADDRSTRLEN);
nm_utils_inet6_ntop (addr, buf);
} else {
@ -210,8 +210,8 @@ add_ip6_config (NMDnsDnsmasq *self, GVariantBuilder *servers, NMIP6Config *ip6,
int nnameservers, i_nameserver, n, i;
gboolean added = FALSE;
g_return_val_if_fail (iface, FALSE);
nnameservers = nm_ip6_config_get_num_nameservers (ip6);
g_assert (iface);
if (split) {
if (nnameservers == 0)

View file

@ -341,7 +341,7 @@ merge_one_ip6_config (NMResolvConfData *rc, NMIP6Config *src, const char *iface)
nm_utils_inet4_ntop (addr->s6_addr32[3], buf);
else {
nm_utils_inet6_ntop (addr, buf);
if (iface && IN6_IS_ADDR_LINKLOCAL (addr)) {
if (IN6_IS_ADDR_LINKLOCAL (addr)) {
g_strlcat (buf, "%", sizeof (buf));
g_strlcat (buf, iface, sizeof (buf));
}
@ -1247,6 +1247,7 @@ nm_dns_manager_add_ip_config (NMDnsManager *self,
g_return_val_if_fail (NM_IS_DNS_MANAGER (self), FALSE);
g_return_val_if_fail (config, FALSE);
g_return_val_if_fail (iface && iface[0], FALSE);
priv = NM_DNS_MANAGER_GET_PRIVATE (self);