From e4b79597a0527d52ba879523dc3791d42c72831f Mon Sep 17 00:00:00 2001 From: Jari Nippula Date: Fri, 8 Nov 2024 16:40:35 +0200 Subject: [PATCH] uxrce_dds_client: UDP transport string null termination fix --- src/modules/uxrce_dds_client/uxrce_dds_client.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modules/uxrce_dds_client/uxrce_dds_client.cpp b/src/modules/uxrce_dds_client/uxrce_dds_client.cpp index 9483fa3d5eff..d9352cbe5fbd 100644 --- a/src/modules/uxrce_dds_client/uxrce_dds_client.cpp +++ b/src/modules/uxrce_dds_client/uxrce_dds_client.cpp @@ -123,9 +123,9 @@ UxrceddsClient::UxrceddsClient(Transport transport, const char *device, int baud #if defined(UXRCE_DDS_CLIENT_UDP) _transport_udp = new uxrUDPTransport(); - strncpy(_send_port, send_port, PORT_MAX_LENGTH - 1); - strncpy(_recv_port, recv_port, PORT_MAX_LENGTH - 1); - strncpy(_agent_ip, agent_ip, AGENT_IP_MAX_LENGTH - 1); + snprintf(_send_port, PORT_MAX_LENGTH, "%s", send_port); + snprintf(_recv_port, PORT_MAX_LENGTH, "%s", recv_port); + snprintf(_agent_ip, AGENT_IP_MAX_LENGTH, "%s", agent_ip); if (_transport_udp) { if (uxr_init_udp_transport(_transport_udp, UXR_IPv4, _agent_ip, _recv_port, _send_port)) {