diff options
author | Thomas Haller <thaller@redhat.com> | 2021-05-06 18:17:14 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2021-06-04 21:31:50 +0200 |
commit | 02fe804f329bde5b02a6411a4ec9b46629127bc1 (patch) | |
tree | f9cab22c71779017901acb808a56f2cf4ef708b6 | |
parent | 17a3d19478367536b066417fb61b94526b493684 (diff) | |
download | NetworkManager-02fe804f329bde5b02a6411a4ec9b46629127bc1.tar.gz |
libnm: fix leak in nm_vpn_service_plugin_read_vpn_details()
Found by Coverity:
Error: RESOURCE_LEAK (CWE-772):
NetworkManager-1.31.3/src/libnm-client-impl/nm-vpn-service-plugin.c:814: alloc_fn: Storage is returned from allocation function "g_string_new".
NetworkManager-1.31.3/src/libnm-client-impl/nm-vpn-service-plugin.c:814: var_assign: Assigning: "key" = storage returned from "g_string_new(line->str + strlen("DATA_KEY="))".
NetworkManager-1.31.3/src/libnm-client-impl/nm-vpn-service-plugin.c:815: var_assign: Assigning: "str" = "key".
NetworkManager-1.31.3/src/libnm-client-impl/nm-vpn-service-plugin.c:855: leaked_storage: Variable "str" going out of scope leaks the storage it points to.
NetworkManager-1.31.3/src/libnm-client-impl/nm-vpn-service-plugin.c:855: leaked_storage: Variable "key" going out of scope leaks the storage it points to.
# 853| NM_SET_OUT(out_secrets, g_steal_pointer(&secrets));
# 854| }
# 855|-> return success;
# 856| }
# 857|
Fixes: 3dfb72b92687 ('service-plugin: allow continuations in the auth-dialog protocol')
(cherry picked from commit 02dbba49d6d316077885c832fba57369cadd4195)
-rw-r--r-- | libnm/nm-vpn-service-plugin.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/libnm/nm-vpn-service-plugin.c b/libnm/nm-vpn-service-plugin.c index 34de21b875..d9888fcc2b 100644 --- a/libnm/nm-vpn-service-plugin.c +++ b/libnm/nm-vpn-service-plugin.c @@ -755,8 +755,9 @@ nm_vpn_service_plugin_read_vpn_details(int fd, GHashTable **out_data, GHashTable gs_unref_hashtable GHashTable *secrets = NULL; gboolean success = FALSE; GHashTable * hash = NULL; - GString * key = NULL, *val = NULL; - nm_auto_free_gstring GString *line = NULL; + nm_auto_free_gstring GString *key = NULL; + nm_auto_free_gstring GString *val = NULL; + nm_auto_free_gstring GString *line = NULL; char c; GString *str = NULL; |