summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2021-05-06 21:35:55 +0200
committerThomas Haller <thaller@redhat.com>2021-05-11 13:56:49 +0200
commit2c628e4762aa6bd97304d3fcca66cc99dee62e34 (patch)
tree09927280ae92c13fc1690b527a0f5f083531d7c5
parentd527d3874c31a6e11c1c59e2454da01fc4e575c3 (diff)
downloadNetworkManager-2c628e4762aa6bd97304d3fcca66cc99dee62e34.tar.gz
libnmc-base:fix leak in NMSecretAgentSimple's request_secrets_from_ui()
Found by Coverity: Error: RESOURCE_LEAK (CWE-772): [#def271] [important] NetworkManager-1.31.3/src/libnmc-base/nm-secret-agent-simple.c:874: alloc_fn: Storage is returned from allocation function "nm_utils_ssid_to_utf8". NetworkManager-1.31.3/src/libnmc-base/nm-secret-agent-simple.c:874: var_assign: Assigning: "ssid_utf8" = storage returned from "nm_utils_ssid_to_utf8(g_bytes_get_data(ssid, NULL), g_bytes_get_size(ssid))". NetworkManager-1.31.3/src/libnmc-base/nm-secret-agent-simple.c:877: noescape: Resource "ssid_utf8" is not freed or pointed-to in "g_strdup_printf". NetworkManager-1.31.3/src/libnmc-base/nm-secret-agent-simple.c:882: leaked_storage: Variable "ssid_utf8" going out of scope leaks the storage it points to. # 880| # 881| if (!add_wireless_secrets(request, secrets)) # 882|-> goto out_fail; # 883| } else if (nm_connection_is_type(request->connection, NM_SETTING_WIRED_SETTING_NAME)) { # 884| title = _("Wired 802.1X authentication"); Error: RESOURCE_LEAK (CWE-772): [#def272] [important] NetworkManager-1.31.3/src/libnmc-base/nm-secret-agent-simple.c:874: alloc_fn: Storage is returned from allocation function "nm_utils_ssid_to_utf8". NetworkManager-1.31.3/src/libnmc-base/nm-secret-agent-simple.c:874: var_assign: Assigning: "ssid_utf8" = storage returned from "nm_utils_ssid_to_utf8(g_bytes_get_data(ssid, NULL), g_bytes_get_size(ssid))". NetworkManager-1.31.3/src/libnmc-base/nm-secret-agent-simple.c:877: noescape: Resource "ssid_utf8" is not freed or pointed-to in "g_strdup_printf". NetworkManager-1.31.3/src/libnmc-base/nm-secret-agent-simple.c:883: leaked_storage: Variable "ssid_utf8" going out of scope leaks the storage it points to. # 881| if (!add_wireless_secrets(request, secrets)) # 882| goto out_fail; # 883|-> } else if (nm_connection_is_type(request->connection, NM_SETTING_WIRED_SETTING_NAME)) { # 884| title = _("Wired 802.1X authentication"); # 885| msg = g_strdup_printf(_("Secrets are required to access the wired network %s"), Fixes: 3fbabde4c3b9 ('libnm-core: replace GByteArray with pointer + length in some APIs')
-rw-r--r--src/libnmc-base/nm-secret-agent-simple.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libnmc-base/nm-secret-agent-simple.c b/src/libnmc-base/nm-secret-agent-simple.c
index 69617d0fee..419a9a6ebf 100644
--- a/src/libnmc-base/nm-secret-agent-simple.c
+++ b/src/libnmc-base/nm-secret-agent-simple.c
@@ -867,7 +867,7 @@ request_secrets_from_ui(RequestData *request)
if (nm_connection_is_type(request->connection, NM_SETTING_WIRELESS_SETTING_NAME)) {
NMSettingWireless *s_wireless;
GBytes * ssid;
- char * ssid_utf8;
+ gs_free char * ssid_utf8 = NULL;
s_wireless = nm_connection_get_setting_wireless(request->connection);
ssid = nm_setting_wireless_get_ssid(s_wireless);