rdisc: don't leak DNSSL domains if they aren't added
If the new DNSSL domain was not used, becuase it was already in the list, the domain string would be leaked.
This commit is contained in:
@@ -160,20 +160,23 @@ add_server (NMRDisc *rdisc, const NMRDiscDNSServer *new)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Copies new->domain if 'new' is added to the dns_domains list */
|
||||||
static gboolean
|
static gboolean
|
||||||
add_domain (NMRDisc *rdisc, const NMRDiscDNSDomain *new)
|
add_domain (NMRDisc *rdisc, const NMRDiscDNSDomain *new)
|
||||||
{
|
{
|
||||||
|
NMRDiscDNSDomain *item;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < rdisc->dns_domains->len; i++) {
|
for (i = 0; i < rdisc->dns_domains->len; i++) {
|
||||||
NMRDiscDNSDomain *item = &g_array_index (rdisc->dns_domains, NMRDiscDNSDomain, i);
|
item = &g_array_index (rdisc->dns_domains, NMRDiscDNSDomain, i);
|
||||||
|
|
||||||
if (!g_strcmp0 (item->domain, new->domain))
|
if (!g_strcmp0 (item->domain, new->domain))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_array_insert_val (rdisc->dns_domains, i, *new);
|
g_array_insert_val (rdisc->dns_domains, i, *new);
|
||||||
|
item = &g_array_index (rdisc->dns_domains, NMRDiscDNSDomain, i);
|
||||||
|
item->domain = g_strdup (new->domain);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -312,6 +315,7 @@ clean_domains (NMRDisc *rdisc, guint32 now, NMRDiscConfigMap *changed, guint32 *
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (now >= expiry) {
|
if (now >= expiry) {
|
||||||
|
g_free (item->domain);
|
||||||
g_array_remove_index (rdisc->dns_domains, i--);
|
g_array_remove_index (rdisc->dns_domains, i--);
|
||||||
*changed |= NM_RDISC_CONFIG_DNS_DOMAINS;
|
*changed |= NM_RDISC_CONFIG_DNS_DOMAINS;
|
||||||
} else if (now >= refresh)
|
} else if (now >= refresh)
|
||||||
@@ -575,7 +579,7 @@ receive_ra (struct ndp *ndp, struct ndp_msg *msg, gpointer user_data)
|
|||||||
NMRDiscDNSDomain dns_domain;
|
NMRDiscDNSDomain dns_domain;
|
||||||
|
|
||||||
memset (&dns_domain, 0, sizeof (dns_domain));
|
memset (&dns_domain, 0, sizeof (dns_domain));
|
||||||
dns_domain.domain = g_strdup (domain);
|
dns_domain.domain = domain;
|
||||||
dns_domain.timestamp = now;
|
dns_domain.timestamp = now;
|
||||||
dns_domain.lifetime = ndp_msg_opt_rdnss_lifetime (msg, offset);
|
dns_domain.lifetime = ndp_msg_opt_rdnss_lifetime (msg, offset);
|
||||||
/* Pad the lifetime somewhat to give a bit of slack in cases
|
/* Pad the lifetime somewhat to give a bit of slack in cases
|
||||||
|
Reference in New Issue
Block a user