summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2021-05-06 21:44:34 +0200
committerThomas Haller <thaller@redhat.com>2021-06-04 21:30:49 +0200
commit2e5c4abc8cd130534500eb60d47dee9ea6bc10b8 (patch)
tree8c9e53a7553efcb2064760e2f67eeb823c16baa6
parent411af763128bc530563d2ed2f6640493cf7bf530 (diff)
downloadNetworkManager-2e5c4abc8cd130534500eb60d47dee9ea6bc10b8.tar.gz
cli: fix leak in print_wifi_connection()
Found by Coverity: Error: RESOURCE_LEAK (CWE-772): [#def297] [important] NetworkManager-1.31.3/src/nmcli/devices.c:4610: alloc_fn: Storage is returned from allocation function "nm_utils_ssid_to_utf8". NetworkManager-1.31.3/src/nmcli/devices.c:4610: var_assign: Assigning: "ssid" = storage returned from "nm_utils_ssid_to_utf8(g_bytes_get_data(ssid_bytes, NULL), g_bytes_get_size(ssid_bytes))". NetworkManager-1.31.3/src/nmcli/devices.c:4612: noescape: Resource "ssid" is not freed or pointed-to in "g_print". NetworkManager-1.31.3/src/nmcli/devices.c:4642: noescape: Resource "ssid" is not freed or pointed-to in "string_append_mecard". NetworkManager-1.31.3/src/nmcli/devices.c:4654: leaked_storage: Variable "ssid" going out of scope leaks the storage it points to. # 4652| # 4653| g_print("\n"); # 4654|-> } # 4655| # 4656| static gboolean Fixes: 7061341a41d5 ('cli: add "nmcli d wifi show"') (cherry picked from commit e5f37477c066233fd8ae3aeaaeeff992ea584d9a)
-rw-r--r--clients/cli/devices.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/clients/cli/devices.c b/clients/cli/devices.c
index eea82653c0..5800fe760d 100644
--- a/clients/cli/devices.c
+++ b/clients/cli/devices.c
@@ -4595,7 +4595,7 @@ print_wifi_connection(const NmcConfig *nmc_config, NMConnection *connection)
const char * psk = NULL;
const char * type = NULL;
GBytes * ssid_bytes;
- char * ssid;
+ gs_free char * ssid = NULL;
GString * string;
s_wireless = nm_connection_get_setting_wireless(connection);