From ab85cdf1ab96c01d887ce8cd0dec4e34d313d116 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Mon, 10 May 2021 11:11:22 +0200 Subject: Constrain connection ID allocation to 24 bits We currently use the local connection ID on the SCU SAP also as local reference on the wire-line SCCP messages. However, the latter only has a 24 bit range, so we should make sure to wrap accordingly on allocation. Change-Id: I414d29271da48ac0b05a688ce9e949a66e4d0d92 Closes: OS#3921 Related: OS#3871 --- src/sccp_scoc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/sccp_scoc.c b/src/sccp_scoc.c index 1ce08f8..244e6d3 100644 --- a/src/sccp_scoc.c +++ b/src/sccp_scoc.c @@ -499,7 +499,10 @@ static struct sccp_connection *conn_create(struct osmo_sccp_user *user) uint32_t conn_id; do { - conn_id = user->inst->next_id++; + /* modulo 2^24 as we currently use the connection ID also as local + * reference, and that is limited to 24 bits */ + user->inst->next_id = (user->inst->next_id + 1) % (1 << 24); + conn_id = user->inst->next_id; } while (conn_find_by_id(user->inst, conn_id)); return conn_create_id(user, conn_id); -- cgit v1.2.3