Change return type of nr_generate_ulsch_pdu() to avoid overflow on the offset variable

This commit is contained in:
matzakos
2020-06-16 17:40:03 +02:00
parent 45ed1e8066
commit 456e6c9207
2 changed files with 5 additions and 4 deletions
+1 -1
View File
@@ -139,7 +139,7 @@ void nr_ue_process_mac_pdu(module_id_t module_idP,
NR_UL_TIME_ALIGNMENT_t *ul_time_alignment);
unsigned char nr_generate_ulsch_pdu(uint8_t *sdus_payload,
uint16_t nr_generate_ulsch_pdu(uint8_t *sdus_payload,
uint8_t *pdu,
uint8_t num_sdus,
uint16_t *sdu_lengths,
+4 -3
View File
@@ -3723,7 +3723,7 @@ void nr_ue_process_mac_pdu(module_id_t module_idP,
/////* ULSCH MAC PDU generation (6.1.2 TS 38.321) */////
////////////////////////////////////////////////////////
unsigned char nr_generate_ulsch_pdu(uint8_t *sdus_payload,
uint16_t nr_generate_ulsch_pdu(uint8_t *sdus_payload,
uint8_t *pdu,
uint8_t num_sdus,
uint16_t *sdu_lengths,
@@ -3738,7 +3738,8 @@ unsigned char nr_generate_ulsch_pdu(uint8_t *sdus_payload,
NR_MAC_SUBHEADER_FIXED *mac_pdu_ptr = (NR_MAC_SUBHEADER_FIXED *) pdu;
unsigned char last_size = 0, i, mac_header_control_elements[16], *ce_ptr, bsr = 0;
int mac_ce_size, offset;
int mac_ce_size;
uint16_t offset = 0;
LOG_D(MAC, "[UE] Generating ULSCH PDU : num_sdus %d\n", num_sdus);
@@ -3888,7 +3889,7 @@ unsigned char nr_generate_ulsch_pdu(uint8_t *sdus_payload,
// compute final offset
offset = ((unsigned char *) mac_pdu_ptr - pdu);
//printf("Offset %d \n", ((unsigned char *) mac_pdu_ptr - mac_pdu));
//printf("Offset %d \n", ((unsigned char *) mac_pdu_ptr - pdu));
return offset;
}