From bae7af9c1362c49fa3b03b96dcfdd2fcebe43090 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Wed, 28 Feb 2018 18:13:56 +0100 Subject: pcu_sock: Don't overflow the timeslot array Don't blindly trust that the ts_nr received on the PCU socket will be small enough to not overflow our timeslot array! Change-Id: Ie9964c8dc0ca7b049da7dfec0ac0a0d3f1aedd45 --- src/common/pcu_sock.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/common/pcu_sock.c b/src/common/pcu_sock.c index b810174f..c8308a9c 100644 --- a/src/common/pcu_sock.c +++ b/src/common/pcu_sock.c @@ -521,6 +521,12 @@ static int pcu_rx_data_req(struct gsm_bts *bts, uint8_t msg_type, rc = -EINVAL; break; } + if (data_req->ts_nr >= ARRAY_SIZE(trx->ts)) { + LOGP(DPCU, LOGL_ERROR, "Received PCU data request with " + "not existing TS %u\n", data_req->ts_nr); + rc = -EINVAL; + break; + } ts = &trx->ts[data_req->ts_nr]; is_ptcch = (data_req->sapi == PCU_IF_SAPI_PTCCH); rc = l1sap_pdch_req(ts, is_ptcch, data_req->fn, data_req->arfcn, -- cgit v1.2.3