aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2021-05-10 11:11:22 +0200
committerHarald Welte <laforge@osmocom.org>2021-05-10 11:14:01 +0200
commitab85cdf1ab96c01d887ce8cd0dec4e34d313d116 (patch)
tree45fbbe9055e4b7002cc89a1c34e45a58415815e6
parenta7c4f97348d415491c64565dfb8defec4c68b3ef (diff)
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
-rw-r--r--src/sccp_scoc.c5
1 files changed, 4 insertions, 1 deletions
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);