From 70924f28b4ce1e0251f5119a0bca610ad06413bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Thu, 15 Jun 2023 07:56:01 +0200 Subject: [PATCH 1/4] fix udp_transport: call freeaddrinfo only if getaddrinfo succeeded (#359) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Otherwise freeaddrinfo can access invalid memory. Signed-off-by: Beat Küng --- src/c/profile/transport/ip/udp/udp_transport_posix.c | 2 +- src/c/profile/transport/ip/udp/udp_transport_posix_nopoll.c | 2 +- src/c/profile/transport/ip/udp/udp_transport_windows.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/c/profile/transport/ip/udp/udp_transport_posix.c b/src/c/profile/transport/ip/udp/udp_transport_posix.c index c9e331032..2801c230c 100644 --- a/src/c/profile/transport/ip/udp/udp_transport_posix.c +++ b/src/c/profile/transport/ip/udp/udp_transport_posix.c @@ -54,8 +54,8 @@ bool uxr_init_udp_platform( break; } } + freeaddrinfo(result); } - freeaddrinfo(result); } return rv; } diff --git a/src/c/profile/transport/ip/udp/udp_transport_posix_nopoll.c b/src/c/profile/transport/ip/udp/udp_transport_posix_nopoll.c index b57211e0e..c93cbfb33 100644 --- a/src/c/profile/transport/ip/udp/udp_transport_posix_nopoll.c +++ b/src/c/profile/transport/ip/udp/udp_transport_posix_nopoll.c @@ -55,8 +55,8 @@ bool uxr_init_udp_platform( break; } } + freeaddrinfo(result); } - freeaddrinfo(result); } return rv; } diff --git a/src/c/profile/transport/ip/udp/udp_transport_windows.c b/src/c/profile/transport/ip/udp/udp_transport_windows.c index 0e3e754bb..c2919357d 100644 --- a/src/c/profile/transport/ip/udp/udp_transport_windows.c +++ b/src/c/profile/transport/ip/udp/udp_transport_windows.c @@ -56,8 +56,8 @@ bool uxr_init_udp_platform( break; } } + freeaddrinfo(result); } - freeaddrinfo(result); } return rv; } From cf9069c497fa96af58052dbdcb17566719ba934c Mon Sep 17 00:00:00 2001 From: Antonio Cuadros <49162117+Acuadros95@users.noreply.github.com> Date: Thu, 22 Jun 2023 07:57:43 +0200 Subject: [PATCH 2/4] Fix fragmentation check on uxr_prepare_reliable_buffer_to_write (#360) * Fix fragmentation check on uxr_prepare_reliable_buffer_to_write Signed-off-by: acuadros95 * Fix length check Signed-off-by: acuadros95 --------- Signed-off-by: acuadros95 --- src/c/core/session/stream/output_reliable_stream.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/c/core/session/stream/output_reliable_stream.c b/src/c/core/session/stream/output_reliable_stream.c index b3ce287dd..93ca6e25a 100644 --- a/src/c/core/session/stream/output_reliable_stream.c +++ b/src/c/core/session/stream/output_reliable_stream.c @@ -62,6 +62,9 @@ bool uxr_prepare_reliable_buffer_to_write( uint8_t* buffer = uxr_get_reliable_buffer(&stream->base, seq_num); size_t buffer_size = uxr_get_reliable_buffer_size(&stream->base, seq_num); + uint16_t available_block_size = (uint16_t)(buffer_capacity - (uint16_t)(stream->offset + SUBHEADER_SIZE)); + size_t remaining_blocks = get_available_free_slots(stream); + // Aligment required for inserting an XRCE subheader buffer_size += ucdr_alignment(buffer_size, 4); @@ -95,7 +98,7 @@ bool uxr_prepare_reliable_buffer_to_write( } } /* Check if the message fit in a fragmented message */ - else + else if (length <= available_block_size * remaining_blocks) { /* Check if the current buffer free space is too small */ if (buffer_size + (size_t)SUBHEADER_SIZE >= buffer_capacity) @@ -105,13 +108,10 @@ bool uxr_prepare_reliable_buffer_to_write( buffer_size = uxr_get_reliable_buffer_size(&stream->base, seq_num); } - size_t remaining_blocks = get_available_free_slots(stream); - - uint16_t available_block_size = (uint16_t)(buffer_capacity - (uint16_t)(stream->offset + SUBHEADER_SIZE)); uint16_t first_fragment_size = (uint16_t)(buffer_capacity - (uint16_t)(buffer_size + SUBHEADER_SIZE)); size_t remaining_size = length - first_fragment_size; - size_t last_fragment_size; - uint16_t necessary_complete_blocks; + size_t last_fragment_size = 0; + uint16_t necessary_complete_blocks = 0; if (0 == (remaining_size % available_block_size)) { last_fragment_size = available_block_size; From 96ec27152d2013ed7c13fb578697178f37d75757 Mon Sep 17 00:00:00 2001 From: acuadros95 Date: Mon, 10 Jul 2023 10:39:28 +0200 Subject: [PATCH 3/4] Bump version Signed-off-by: acuadros95 --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3518e41f8..9747f551b 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -81,8 +81,8 @@ set(UCLIENT_C_STANDARD 99 CACHE STRING "Version of the C language used to build ############################################################################### # Dependencies ############################################################################### -set(_microcdr_version 2.0.1) -set(_microcdr_tag v2.0.1) +set(_microcdr_version 2.0.2) +set(_microcdr_tag v2.0.2) set(_deps "") list(APPEND _deps "microcdr\;${_microcdr_version}") @@ -92,7 +92,7 @@ list(APPEND _deps "microcdr\;${_microcdr_version}") ############################################################################### set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules) if(NOT UCLIENT_SUPERBUILD) - project(microxrcedds_client VERSION "2.4.0" LANGUAGES C) + project(microxrcedds_client VERSION "2.4.1" LANGUAGES C) else() project(uclient_superbuild NONE) include(${PROJECT_SOURCE_DIR}/cmake/SuperBuild.cmake) From b8dbfaa775d0d842edfa9a0eb2ebc8ebdb1a0c14 Mon Sep 17 00:00:00 2001 From: acuadros95 Date: Mon, 10 Jul 2023 10:57:50 +0200 Subject: [PATCH 4/4] Revert micro-CDR bump version Signed-off-by: acuadros95 --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9747f551b..d256bb7d7 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -81,8 +81,8 @@ set(UCLIENT_C_STANDARD 99 CACHE STRING "Version of the C language used to build ############################################################################### # Dependencies ############################################################################### -set(_microcdr_version 2.0.2) -set(_microcdr_tag v2.0.2) +set(_microcdr_version 2.0.1) +set(_microcdr_tag v2.0.1) set(_deps "") list(APPEND _deps "microcdr\;${_microcdr_version}")