libteamdctl: validate the bus name before using it

Using bus name without validating it will cause core dump generated,
and it can be reproduced by:

  # ip link add dummy0.1 type dummy
  # teamdctl dummy0.1 state dump

  This is normally a bug in some application using the D-Bus library.

    D-Bus not built with -rdynamic so unable to print a backtrace
  Aborted (core dumped)

Doing this many times can even create too many core files, customers
may complain about it.

This is triggered when calling cli_method_call("ConfigDump") in
cli_init(), so fix it by returning err in cli->init/cli_dbus_init()
if the bus name fails to validate.

Note this is safe, as with dbus, we can't use invalid dbus name to
create the team dev either.

Fixes: d8163e34c25c ("libteamdctl: do test method call instead or Introspect call")
Reported-by: Uday Patel <>
Signed-off-by: Xin Long <>
Signed-off-by: Jiri Pirko <>
1 file changed