[PATCH 4/4] netconfig: Fix leaking domain name string
Andrew Zaborowski <[email protected]>
| Newsgroups | dev.linux.lists.ell |
|---|---|
| Message-ID | <[email protected]> |
In l_netconfig_get_domain_names we had two
l_dhcp_lease_get_domain_name() calls and only saved one of the values.
l_dhcp_lease_get_domain_name() internally does an strdup so we own the
returned string.
Reported by Coverity Scan as CID 379209.
---
ell/netconfig.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/ell/netconfig.c b/ell/netconfig.c
index f48018b..28afa9b 100644
--- a/ell/netconfig.c
+++ b/ell/netconfig.c
@@ -1908,15 +1908,16 @@ LIB_EXPORT char **l_netconfig_get_domain_names(struct l_netconfig *netconfig)
char **ret = NULL;
const struct l_dhcp_lease *v4_lease;
const struct l_dhcp6_lease *v6_lease;
+ char *dn;
if (netconfig->v4_domain_names_override)
netconfig_strv_cat(&ret, netconfig->v4_domain_names_override,
false);
else if ((v4_lease =
l_dhcp_client_get_lease(netconfig->dhcp_client)) &&
- l_dhcp_lease_get_domain_name(v4_lease)) {
+ (dn = l_dhcp_lease_get_domain_name(v4_lease))) {
ret = l_new(char *, 2);
- ret[0] = l_dhcp_lease_get_domain_name(v4_lease);
+ ret[0] = dn;
}
if (netconfig->v6_dns_override)
--
2.34.1