From b53da22eb1e386f5fe7d405cf9588d81f9f8496a Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Wed, 12 Jan 2022 16:22:43 +0000 Subject: [PATCH] lib,rlc: changed return of string helper functions from char* to std::string to avoid UB --- lib/include/srsran/rlc/rlc_am_lte_packing.h | 4 ++-- lib/src/rlc/rlc_am_lte.cc | 2 +- lib/src/rlc/rlc_am_lte_packing.cc | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/include/srsran/rlc/rlc_am_lte_packing.h b/lib/include/srsran/rlc/rlc_am_lte_packing.h index affba5dff..1ddb16b6a 100644 --- a/lib/include/srsran/rlc/rlc_am_lte_packing.h +++ b/lib/include/srsran/rlc/rlc_am_lte_packing.h @@ -62,8 +62,8 @@ bool rlc_am_is_unaligned(const uint8_t fi); bool rlc_am_not_start_aligned(const uint8_t fi); std::string rlc_am_undelivered_sdu_info_to_string(const std::map >& info_queue); -const char* rlc_amd_pdu_header_to_string(const rlc_amd_pdu_header_t& header); -const char* rlc_am_status_pdu_to_string(rlc_status_pdu_t* status); +std::string rlc_amd_pdu_header_to_string(const rlc_amd_pdu_header_t& header); +std::string rlc_am_status_pdu_to_string(rlc_status_pdu_t* status); } // namespace srsran #endif // SRSRAN_RLC_AM_LTE_PACKING_H diff --git a/lib/src/rlc/rlc_am_lte.cc b/lib/src/rlc/rlc_am_lte.cc index 710dd3413..057a2a15c 100644 --- a/lib/src/rlc/rlc_am_lte.cc +++ b/lib/src/rlc/rlc_am_lte.cc @@ -420,7 +420,7 @@ bool rlc_am_lte_tx::poll_required() /* According to 5.2.2.1 in 36.322 v13.3.0 a poll should be requested if * the entire AM window is unacknowledged, i.e. no new PDU can be transmitted. - * However, it seems more appropiate to request more often if polling + * However, it seems more appropriate to request more often if polling * is disabled otherwise, e.g. every N PDUs. */ if (cfg.poll_pdu == 0 && cfg.poll_byte == 0 && vt_s % rlc_am::poll_periodicity == 0) { diff --git a/lib/src/rlc/rlc_am_lte_packing.cc b/lib/src/rlc/rlc_am_lte_packing.cc index 44a288b8f..e6a451a56 100644 --- a/lib/src/rlc/rlc_am_lte_packing.cc +++ b/lib/src/rlc/rlc_am_lte_packing.cc @@ -312,7 +312,7 @@ bool rlc_am_not_start_aligned(const uint8_t fi) /** * Logging helpers */ -const char* rlc_amd_pdu_header_to_string(const rlc_amd_pdu_header_t& header) +std::string rlc_amd_pdu_header_to_string(const rlc_amd_pdu_header_t& header) { fmt::memory_buffer buffer; fmt::format_to(buffer, @@ -334,10 +334,10 @@ const char* rlc_amd_pdu_header_to_string(const rlc_amd_pdu_header_t& header) } fmt::format_to(buffer, "]"); - return to_c_str(buffer); + return fmt::to_string(buffer); } -const char* rlc_am_status_pdu_to_string(rlc_status_pdu_t* status) +std::string rlc_am_status_pdu_to_string(rlc_status_pdu_t* status) { fmt::memory_buffer buffer; fmt::format_to(buffer, "ACK_SN = {}, N_nack = {}", status->ack_sn, status->N_nack); @@ -352,7 +352,7 @@ const char* rlc_am_status_pdu_to_string(rlc_status_pdu_t* status) } } } - return to_c_str(buffer); + return fmt::to_string(buffer); } } // namespace srsran