rmw_connext icon indicating copy to clipboard operation
rmw_connext copied to clipboard

Several function calls are not checked for returns / Sequence lengths are not checked

Open dejanpan opened this issue 8 years ago • 1 comments

Bug report

  1. Several function calls are not checked for returns: see here https://github.com/ros2/rmw_connext/search?utf8=%E2%9C%93&q=return_loan&type=

  2. Sequence lengths are not checked before accessed: https://github.com/ros2/rmw_connext/search?utf8=%E2%9C%93&q=DDS_SampleInfo+%26+sample_info+%3D+sample_infos%5B0%5D%3B&type=

I am running out of time to fix now but can do next month if noone else comes to it.

dejanpan avatar Feb 13 '18 02:02 dejanpan

If someone comes to fix this, here would be another fix to be made. Return value of type support getter is not checked and callback pointer is not checked too.

  1. https://github.com/ros2/rmw_connext/blob/master/rosidl_typesupport_connext_c/resource/msg__type_support_c.cpp.em#L171
  2. https://github.com/ros2/rmw_connext/blob/master/rosidl_typesupport_connext_c/resource/msg__type_support_c.cpp.em#L389
  3. https://github.com/ros2/rmw_connext/blob/master/rosidl_typesupport_connext_c/resource/msg__type_support_c.cpp.em#L411

The code could be something like this:

const rosidl_message_type_support_t * rosidl_message_type_support_ptr =
      ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME(rosidl_typesupport_connext_c, @(field.type.pkg_name), msg, @(field.type.type))();
    if (rosidl_message_type_support_ptr == NULL)
    {
      throw std::runtime_error("rosidl_message_type_support_ptr == NULL");
    }
    const message_type_support_callbacks_t * @(field.type.pkg_name)__msg__@(field.type.type)__callbacks =
      static_cast<const message_type_support_callbacks_t *>(rosidl_message_type_support_ptr->data);
    if (@(field.type.pkg_name)__msg__@(field.type.type)__callbacks == NULL)
    {
      throw std::runtime_error("@(field.type.pkg_name)__msg__@(field.type.type)__callbacks == NULL");
    }

dejanpan avatar Feb 13 '18 02:02 dejanpan

Closing, since with Foxy now being End-of-Life, this repository is no longer used.

clalancette avatar Jun 21 '23 20:06 clalancette