Skip to content

Commit

Permalink
Length of size limited string is not checked
Browse files Browse the repository at this point in the history
  • Loading branch information
fujitatomoya committed Nov 22, 2021
1 parent 9290736 commit fabd65b
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 1 deletion.
4 changes: 4 additions & 0 deletions prover_interfaces/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ find_package(rosidl_default_generators REQUIRED)
# further dependencies manually.
# find_package(<dependency> REQUIRED)

set(msg_files
"msg/StringLengthTest.msg"
)
set(srv_files
"srv/Huge.srv"
)
rosidl_generate_interfaces(${PROJECT_NAME}
${msg_files}
${srv_files}
ADD_LINTER_TESTS
)
Expand Down
1 change: 1 addition & 0 deletions prover_interfaces/msg/StringLengthTest.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
string<=10 size_limited_string
3 changes: 3 additions & 0 deletions prover_rclcpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ find_package(rcutils)
find_package(rmw REQUIRED)
find_package(std_srvs REQUIRED)
find_package(std_msgs REQUIRED)
find_package(prover_interfaces REQUIRED)
find_package(example_interfaces REQUIRED)

function(custom_executable target)
Expand All @@ -45,6 +46,7 @@ function(custom_executable target)
"rclcpp"
"std_srvs"
"std_msgs"
"prover_interfaces"
"lifecycle_msgs"
"rclcpp_lifecycle"
"example_interfaces")
Expand Down Expand Up @@ -82,6 +84,7 @@ custom_executable(rclcpp_1746)
custom_executable(rclcpp_1766)
custom_executable(rclcpp_1778)
custom_executable(rclcpp_1785)
custom_executable(rclcpp_1827)

custom_executable(rmw_fastrtps_554)
custom_executable(rmw_fastrtps_555)
Expand Down
4 changes: 3 additions & 1 deletion prover_rclcpp/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<build_depend>rmw_implementation_cmake</build_depend>
<build_depend>std_msgs</build_depend>
<build_depend>std_srvs</build_depend>
<build_depend>prover_interfaces</build_depend>
<build_depend>example_interfaces</build_depend>

<exec_depend>lifecycle_msgs</exec_depend>
Expand All @@ -32,7 +33,8 @@
<exec_depend>rmw</exec_depend>
<exec_depend>std_msgs</exec_depend>
<exec_depend>std_srvs</exec_depend>
<build_depend>example_interfaces</build_depend>
<exec_depend>prover_interfaces</exec_depend>
<exec_depend>example_interfaces</exec_depend>

<test_depend>ament_cmake_pytest</test_depend>
<test_depend>ament_lint_auto</test_depend>
Expand Down
38 changes: 38 additions & 0 deletions prover_rclcpp/src/rclcpp_1827.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include <chrono>
#include <memory>

using namespace std::chrono_literals;

#include "rclcpp/rclcpp.hpp"
#include "prover_interfaces/msg/string_length_test.hpp"

class TestPublisher : public rclcpp::Node
{
public:
TestPublisher()
: Node("string_length_test_publisher")
{
publisher_ = this->create_publisher<prover_interfaces::msg::StringLengthTest>("oversized", 10);
timer_ = this->create_wall_timer(
1s, std::bind(&TestPublisher::timer_callback, this)); // 1kHz
}

private:
void timer_callback()
{
auto message = prover_interfaces::msg::StringLengthTest();
message.size_limited_string.resize(11, 'x');
publisher_->publish(message);
}
rclcpp::TimerBase::SharedPtr timer_;
rclcpp::Publisher<prover_interfaces::msg::StringLengthTest>::SharedPtr publisher_;
};

int main(int argc, char **argv)
{
rclcpp::init(argc, argv);
std::shared_ptr<TestPublisher> pub = std::make_shared<TestPublisher>();
rclcpp::spin(pub);
rclcpp::shutdown();
return 0;
}

0 comments on commit fabd65b

Please sign in to comment.