diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2022-10-19 11:41:13 +0200 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2022-10-19 16:11:55 +0200 |
commit | 40897db05614df8ef3cf0fd3dc407fabcca5536e (patch) | |
tree | f217ee7b8344a857ea71939ff8cb91c785461c98 | |
parent | 4ffb7cba7b4ed7bb8bf6ee3ae38140396c4d0572 (diff) |
nmcli: fix crash in "nmcli device monitor"
Fix the following crash:
$ nmcli device monitor a
Error: Device 'a' not found.
Segmentation fault (core dumped)
Found by coverity:
1. NetworkManager-1.41.3/src/nmcli/devices.c:0: scope_hint: In function 'do_devices_monitor'
2. NetworkManager-1.41.3/src/nmcli/devices.c:2932:28: warning[-Wanalyzer-null-dereference]: dereference of NULL 'devices'
2930| }
2931|
2932|-> for (i = 0; i < devices->len; i++)
2933| device_watch(nmc, g_ptr_array_index(devices, i));
2934|
Fixes: 2074b2897627 ('nmcli/devices: return GPtrArray instead of GSList from get_device_list()')
-rw-r--r-- | src/nmcli/devices.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/nmcli/devices.c b/src/nmcli/devices.c index b449383034..f26519bfcf 100644 --- a/src/nmcli/devices.c +++ b/src/nmcli/devices.c @@ -2920,6 +2920,8 @@ do_devices_monitor(const NMCCommand *cmd, NmCli *nmc, int argc, const char *cons nmc->return_value = NMC_RESULT_ERROR_USER_INPUT; return; } + if (!devices) + return; } else { /* No devices specified. Monitor all. */ devices = nm_client_get_devices(nmc->client); |