From 0e9b0beda3a72d246c7136b1c458125828d41a6e Mon Sep 17 00:00:00 2001 From: Sai Kishor Kothakota Date: Wed, 6 Sep 2023 23:59:09 +0200 Subject: [PATCH] fix potential bug of matching substrings --- controller_manager/src/controller_manager.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/controller_manager/src/controller_manager.cpp b/controller_manager/src/controller_manager.cpp index 98e8cbffc7..3b32d72bb0 100644 --- a/controller_manager/src/controller_manager.cpp +++ b/controller_manager/src/controller_manager.cpp @@ -209,7 +209,8 @@ std::vector get_preceding_controller_names( auto cmd_itfs = ctrl.c->command_interface_configuration().names; for (const auto & itf : cmd_itfs) { - if (itf.find(controller_name) != std::string::npos) + auto split_pos = itf.find_first_of('/'); + if ((split_pos != std::string::npos) && (itf.substr(0, split_pos) == controller_name)) { preceding_controllers.push_back(ctrl.info.name); auto ctrl_names = get_preceding_controller_names(ctrl.info.name, controllers);