From b991b0716795b1fd06ef81f0e3f0574f696e36b9 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Sat, 10 Apr 2021 12:38:28 +0200 Subject: [PATCH] rlc: add length check for RLC PDU generation makes sure that RLC doesn't generate a PDU larger than the provided grant size --- lib/src/upper/rlc.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/src/upper/rlc.cc b/lib/src/upper/rlc.cc index 807cf46ef..81b25add9 100644 --- a/lib/src/upper/rlc.cc +++ b/lib/src/upper/rlc.cc @@ -294,6 +294,8 @@ int rlc::read_pdu(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes) logger.warning("LCID %d doesn't exist.", lcid); } + srsran_expect(ret <= nof_bytes, "Created too big RLC PDU (%d > %d)", ret, nof_bytes); + return ret; } @@ -309,6 +311,8 @@ int rlc::read_pdu_mch(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes) logger.warning("LCID %d doesn't exist.", lcid); } + srsran_expect(ret <= nof_bytes, "Created too big RLC PDU for MCH (%d > %d)", ret, nof_bytes); + return ret; }