eclipse-cyclonedds / cyclonedds

Eclipse Cyclone DDS project
https://projects.eclipse.org/projects/iot.cyclonedds
Other
888 stars 363 forks source link

tcp can not work. because of Zero Pointer Access #1247

Open johnflj opened 2 years ago

johnflj commented 2 years ago

when using tcp. helloworld will error. because of Zero Pointer Access in function (calc_locator_cost) image

I think.we can add code in ddsi_tcp_create_conn : static dds_return_t ddsi_tcp_create_conn (ddsi_tran_conn_t conn_out, struct ddsi_tran_factory fact_cmn, uint32_t port, const struct ddsi_tran_qos qos) { struct ddsi_tran_factory_tcp const fact = (struct ddsi_tran_factory_tcp *) fact_cmn; (void) qos; (void) port;

/ In the cycloneDDS code, when using a tcp connection, in the function calc_locator_cost, m_interf is used to get the necessary properties, but this variable is not assigned anywhere, so we do that here. / struct ddsi_domaingv const const gv = fact->fact.gv; struct nn_interface const const intf = qos->m_interface ? qos->m_interface : &gv->interfaces[0];

fact->ddsi_tcp_conn_client.m_base.m_interf = intf; *conn_out = &fact->ddsi_tcp_conn_client.m_base;

return DDS_RETCODE_OK; }

and tcp will ok.

eboasson commented 2 years ago

That's a clever workaround 🙂 Arguably, you could abuse it because where it crashes it is looking at multicast-related settings that are completely irrelevant to TCP, but it seems to me that there are a few other ways in which such abuse could happen anyway.

I'd be happy to merge it. Do you fancy doing a PR for that? If not, I'll do it.