lib,rlc_am_nr: added assert to double check nof_bytes before memcopying into the payload on build_retx_pdu_without_segmentation()

This commit is contained in:
Pedro Alvarez 2022-02-09 11:17:10 +01:00
parent 871142b722
commit c47be649f4
1 changed files with 6 additions and 4 deletions

View File

@ -490,17 +490,19 @@ uint32_t rlc_am_nr_tx::build_retx_pdu_without_segmentation(rlc_amd_retx_t& retx,
}
uint32_t hdr_len = rlc_am_nr_write_data_pdu_header(new_header, payload);
uint32_t pdu_bytes = 0;
uint32_t pdu_bytes = 0;
uint32_t retx_pdu_payload_size = 0;
if (not retx.is_segment) {
// RETX full SDU
memcpy(&payload[hdr_len], tx_window[retx.sn].sdu_buf->msg, tx_window[retx.sn].sdu_buf->N_bytes);
pdu_bytes = hdr_len + tx_window[retx.sn].sdu_buf->N_bytes;
retx_pdu_payload_size = tx_window[retx.sn].sdu_buf->N_bytes;
pdu_bytes = hdr_len + tx_window[retx.sn].sdu_buf->N_bytes;
} else {
// RETX SDU segment
uint32_t retx_pdu_payload_size = (retx.so_end - retx.current_so);
pdu_bytes = hdr_len + retx_pdu_payload_size;
memcpy(&payload[hdr_len], &tx_pdu.sdu_buf->msg[retx.current_so], retx_pdu_payload_size);
}
srsran_assert(pdu_bytes <= nof_bytes, "Error calculating hdr_len and pdu_payload_len");
memcpy(&payload[hdr_len], &tx_pdu.sdu_buf->msg[retx.current_so], retx_pdu_payload_size);
retx_queue.pop();
RlcHexInfo(tx_window[retx.sn].sdu_buf->msg,