From bb8990582fcbb750d71e7d38414948aed6c98524 Mon Sep 17 00:00:00 2001 From: Daniel Willmann Date: Sat, 16 Jan 2021 14:02:45 +0100 Subject: 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 --- src/gb/gprs_ns2.c | 3 +++ 1 file changed, 3 insertions(+) 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) -- cgit v1.2.3