diff options
author | Andrew Zaborowski <andrew.zaborowski@intel.com> | 2022-07-01 15:32:37 +0200 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2022-07-01 10:11:06 -0500 |
commit | a501e4dccf9323044469e48475762f876478ab52 (patch) | |
tree | 91979f61610cbeb9fe77f913bc5f43ebe171a16f | |
parent | 3a1537c102495fe0d129fd0dcb89e1aeab370141 (diff) |
netconfig: Fix leaking domain name string
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.
-rw-r--r-- | ell/netconfig.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/ell/netconfig.c b/ell/netconfig.c index f48018bb..28afa9bf 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) |