summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2019-08-02 08:33:32 +0200
committerThomas Haller <thaller@redhat.com>2019-08-02 11:10:50 +0200
commit650c0cd622fb63c5b64214bd3f7c84c0dbef8b8b (patch)
treecae8cdd31884da346bfb9c127dd83764c43205e5
parentae1f6de8993f7693548b0f75625628eccf2e2ad1 (diff)
downloadNetworkManager-650c0cd622fb63c5b64214bd3f7c84c0dbef8b8b.tar.gz
cli: fix dereferncing NULL pointer in parse_passwords() with empty file
Warned by coverity. (cherry picked from commit ec982ceb8ebc9a2f9c3ee14f89735bce818ee948)
-rw-r--r--clients/cli/connections.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/clients/cli/connections.c b/clients/cli/connections.c
index 385587d60f..e365980eb0 100644
--- a/clients/cli/connections.c
+++ b/clients/cli/connections.c
@@ -2711,7 +2711,6 @@ parse_passwords (const char *passwd_file, GError **error)
if (!passwd_file)
return g_steal_pointer (&pwds_hash);
- /* Read the passwords file */
if (!g_file_get_contents (passwd_file, &contents, &len, &local_err)) {
g_set_error (error, NMCLI_ERROR, NMC_RESULT_ERROR_USER_INPUT,
_("failed to read passwd-file '%s': %s"),
@@ -2721,7 +2720,7 @@ parse_passwords (const char *passwd_file, GError **error)
}
strv = nm_utils_strsplit_set (contents, "\r\n");
- for (iter = strv; *iter; iter++) {
+ for (iter = strv; strv && *iter; iter++) {
gs_free char *iter_s = g_strdup (*iter);
pwd = strchr (iter_s, ':');