Skip to content

nmcli/edit: fix an assertion failure when tab-completing bad setting name

Lubomir Rintel requested to merge lr/sad-nmcli-edit into main

Attempt to tab-complete a property from a setting which does not exist results in an assertion failure:

      nmcli > set lala.lala<TAB>
    
      (process:597363): nm-CRITICAL **: 16:30:21.642: nm_meta_setting_info_editor_find_by_name: assertion 'setting_name' failed
    
      Thread 1 "nmcli" received signal SIGTRAP, Trace/breakpoint trap.
      0x00007ffff780dc28 in g_logv () from /lib64/libglib-2.0.so.0
      (gdb) bt
      #0  0x00007ffff780dc28 in g_logv () at /lib64/libglib-2.0.so.0
      #1  0x00007ffff780dea3 in g_log () at /lib64/libglib-2.0.so.0
      #2  0x000000000044a2c2 in nm_meta_setting_info_editor_find_by_name (setting_name=<optimized out>, use_alias=use_alias@entry=0)
          at src/libnmc-setting/nm-meta-setting-access.c:35
      #3  0x000000000042eb07 in get_setting_and_property (prompt=<optimized out>, line=<optimized out>, setting_out=0x7fffffffcf10, property_out=0x7fffffffcf18)
          at src/nmcli/connections.c:6639
      #4  0x000000000042ec38 in get_allowed_property_values (out_to_free=out_to_free@entry=0x7fffffffcf50) at src/nmcli/connections.c:6711
      #5  0x000000000042ed8c in should_complete_property_values (prompt=prompt@entry=0x5befb0 "nmcli 802-1x.pac-file> ", line=line@entry=0x0, multi=multi@entry=0x7fffffffcfe4)
          at src/nmcli/connections.c:6735
      #6  0x000000000042f5d8 in nmcli_editor_tab_completion (text=0x5bef90 "lala", start=<optimized out>, end=13) at src/nmcli/connections.c:6899
      #7  0x00007ffff776dcdc in gen_completion_matches () at /lib64/libreadline.so.8
      ...

Do not proceed resolving the setting name if it does not pass check_valid_name().

Merge request reports