aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Willmann <dwillmann@sysmocom.de>2021-01-16 14:02:45 +0100
committerDaniel Willmann <dwillmann@sysmocom.de>2021-01-16 19:47:32 +0100
commitbb8990582fcbb750d71e7d38414948aed6c98524 (patch)
tree6eb176166cb1b73b5b8eb0fa0b2f46c4da2a61e8
parent967e2c186820ea9f250f3b1cd2af4a3974c4fe7e (diff)
ns2: Add sanity check
Prevent memory corruption or segfaults by asserting that NSE and bind link layer match. A mismatch should never happen and might cause the bind to access invalid memory when sending because nsvc->priv doesn't match what it expects. Change-Id: I7ca4cd1c5dac8b5e44ffc4825b9373b2d04911ab Related: OS#4948
-rw-r--r--src/gb/gprs_ns2.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/gb/gprs_ns2.c b/src/gb/gprs_ns2.c
index e43b6365..3ca87a4b 100644
--- a/src/gb/gprs_ns2.c
+++ b/src/gb/gprs_ns2.c
@@ -490,6 +490,9 @@ void ns2_prim_status_ind(struct gprs_ns2_nse *nse,
struct gprs_ns2_vc *ns2_vc_alloc(struct gprs_ns2_vc_bind *bind, struct gprs_ns2_nse *nse, bool initiater,
enum gprs_ns2_vc_mode vc_mode)
{
+ /* Sanity check */
+ OSMO_ASSERT(bind->ll == nse->ll);
+
struct gprs_ns2_vc *nsvc = talloc_zero(bind, struct gprs_ns2_vc);
if (!nsvc)