From 35aa665337499ac83a1dbd46b0f77a57b82fd993 Mon Sep 17 00:00:00 2001 From: Guillaume Nault Date: Wed, 26 Oct 2016 14:00:48 +0200 Subject: l2tp: fix l2tp_ctx_switch() There are three different triton contexts that use l2tp_ctx_switch() as their ->before_switch callback (main UDP server, L2TP control and L2TP data). In UDP server and L2TP control contexts, l2tp_ctx_switch() is called with 'arg' == NULL. Only L2TP data contexts pass an ap_session pointer. So we have to check 'arg' before setting 'net' or accel-ppp would segfaults. Signed-off-by: Guillaume Nault --- accel-pppd/ctrl/l2tp/l2tp.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'accel-pppd/ctrl') diff --git a/accel-pppd/ctrl/l2tp/l2tp.c b/accel-pppd/ctrl/l2tp/l2tp.c index 5d9041fa..bb3df4d4 100644 --- a/accel-pppd/ctrl/l2tp/l2tp.c +++ b/accel-pppd/ctrl/l2tp/l2tp.c @@ -255,8 +255,13 @@ static inline int nsnr_cmp(uint16_t ns, uint16_t nr) static void l2tp_ctx_switch(struct triton_context_t *ctx, void *arg) { - struct ap_session *s = arg; - net = s->net; + struct ap_session *apses = arg; + + if (apses) + net = apses->net; + else + net = def_net; + log_switch(ctx, arg); } -- cgit v1.2.3