mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-10-15 04:24:32 +00:00
cli: fix accessing argv with zero elements in nmc_process_connection_properties()
Without this, `nmcli device modify "$DEVICE"` leads to a crash. At least since commitc5d45848dd
('cli: mark argv argument for command line parsing as const'), when this happens. That is, because it passes a NULL strv array with argc being set to zero. nmc_process_connection_properties() is not supposed to access the array, if there are no elements there. Fixes:c5d45848dd
('cli: mark argv argument for command line parsing as const') https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/492
This commit is contained in:
parent
16abfca78a
commit
09c94bc24f
|
@ -4709,13 +4709,18 @@ nmc_process_connection_properties (NmCli *nmc,
|
|||
ensure_settings (connection, slv_settings);
|
||||
ensure_settings (connection, type_settings);
|
||||
|
||||
option_orig = **argv;
|
||||
if (!option_orig) {
|
||||
if (*argc <= 0) {
|
||||
g_set_error_literal (error, NMCLI_ERROR, NMC_RESULT_ERROR_USER_INPUT,
|
||||
_("Error: <setting>.<property> argument is missing."));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
nm_assert (argv);
|
||||
nm_assert (*argv);
|
||||
nm_assert (**argv);
|
||||
|
||||
option_orig = **argv;
|
||||
|
||||
switch (option_orig[0]) {
|
||||
case '+': modifier = NM_META_ACCESSOR_MODIFIER_ADD; option = &option_orig[1]; break;
|
||||
case '-': modifier = NM_META_ACCESSOR_MODIFIER_DEL; option = &option_orig[1]; break;
|
||||
|
|
Loading…
Reference in a new issue