From a1d95018b8e1daa88e50350da3fe8a2e26c86b66 Mon Sep 17 00:00:00 2001 From: Lorenzo Miniero Date: Tue, 3 Nov 2020 15:25:24 +0100 Subject: [PATCH] Make sure the WWW-Authentication header exists when handling REGISTER challenges (fixes #2419) --- plugins/janus_sip.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/plugins/janus_sip.c b/plugins/janus_sip.c index dcc6da0d75..30edbe66f0 100644 --- a/plugins/janus_sip.c +++ b/plugins/janus_sip.c @@ -5479,11 +5479,19 @@ void janus_sip_sofia_callback(nua_event_t event, int status, char const *phrase, if(status == 401) { /* Get scheme/realm from 401 error */ sip_www_authenticate_t const* www_auth = sip->sip_www_authenticate; + if(www_auth == NULL) { + /* No WWW-Authenticate header, give up */ + goto auth_failed; + } scheme = www_auth->au_scheme; realm = msg_params_find(www_auth->au_params, "realm="); } else { /* Get scheme/realm from 407 error, proxy-auth */ sip_proxy_authenticate_t const* proxy_auth = sip->sip_proxy_authenticate; + if(proxy_auth == NULL) { + /* No Proxy-Authenticate header, give up */ + goto auth_failed; + } scheme = proxy_auth->au_scheme; realm = msg_params_find(proxy_auth->au_params, "realm="); } @@ -5517,6 +5525,7 @@ void janus_sip_sofia_callback(nua_event_t event, int status, char const *phrase, NUTAG_AUTH(auth), TAG_END()); } else if(status >= 400) { +auth_failed: /* Authentication failed? */ session->account.registration_status = janus_sip_registration_status_failed; /* Cleanup registration values */