From d795c7299084676d5194749ede702d650a1674e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=BAben=20Soares=20Silva?= Date: Mon, 1 Jul 2024 11:38:16 +0100 Subject: [PATCH] Change compute_PDU_Length input parameter to uint32_t. The total_length parameter in compute_PDU_Length being uint16_t causes the passed value to be possibly truncated, which can cause the PDU_Length to be incorrectly calculated. This change prevents that truncation, since it now matches the size of the values passed into the function where it is being called. --- openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c | 2 +- openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c index d612a6dcc6..879bfb0516 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c @@ -5200,7 +5200,7 @@ bool supported_bw_comparison(int bw_mhz, NR_SupportedBandwidth_t *supported_BW, return false; } -uint32_t compute_PDU_length(uint32_t num_TLV, uint16_t total_length) +uint32_t compute_PDU_length(uint32_t num_TLV, uint32_t total_length) { uint32_t pdu_length = 8; // 2 bytes PDU_Length + 2 bytes PDU_Index + 4 bytes num_TLV // For each TLV, add 2 bytes tag + 2 bytes length + value size without padding diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h index 32c8242f35..e809c3e521 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h @@ -311,7 +311,7 @@ void compute_csi_bitlen(const NR_CSI_MeasConfig_t *csi_MeasConfig, nr_csi_report uint16_t nr_get_csi_bitlen(nr_csi_report_t *csi_report); -uint32_t compute_PDU_length(uint32_t num_TLV, uint16_t total_length); +uint32_t compute_PDU_length(uint32_t num_TLV, uint32_t total_length); rnti_t nr_get_ra_rnti(uint8_t s_id, uint8_t t_id, uint8_t f_id, uint8_t ul_carrier_id);